Tag Archives: Phpcloud

Using Mongo with PHPCloud

With the release that occurred on March 4th we have added Mongo support to the DevCloud.  So connecting to a Mongo instance is extremely easy to do now.  We don’t provide access to a Mongo collection but you do have the tools to connect to various Mongo service providers.  For this example I used MongoHQ though any service running Mongo sound work.

First go to whichever service you are using and create a new collection.  Like this

Then click on the Zend Server link for your container.  Like this

Go to Server Setup / Extensions and enable Mongo.  Like this

Restart Zend Server and deploy code.  Like this

1
2
3
4
5
6
7
8
9
10
11
$db = new Mongo('mongodb://kschroeder:[email protected]:10050/kschroeder');
 
$collection = $db->kschroeder->views;
 
$collection->insert(
array(
'view' => new MongoDate()
)
);
 
echo $collection->count() . ' views on this page';

Now you’re doing Mongo on the DevCloud like a boss.

It took me all of 10 minutes to do this.

Using Jabber/XMPP for event notification with Zend Server and/or PHPCloud

I have removed this service due to possible abuse.  It was intended to be a test and I think I’ve gotten what I need

 

There was something I’ve wanted to try for a little while.  Messaging is something that’s interested me and with all of the work I’ve been doing on the Zend Developer Cloud I’ve been interested in seeing how to make things communicate a little better.  One of the ideas I’ve wanted to try was to use instant messaging for notification when  slow request or large memory usage events occur.

So to test this out I decided to write a handler that would take events and pass them off to a Jabber server.  That way when the events occur they’ll be passed to your IM client instead of flooding your email client.

It took a little longer than I wanted, mostly due to the fact that the XMPP protocol is new to me, many of the examples don’t work and it required setting up a server that I was not familiar with.  I ended up using the XMPPHP library and the Openfire server to do my dirty work.  I used PHPCloud as dev environment.

So what I’m going to do is open it up to anyone who wants to try it.  I make no guarantees as to its usefulness or stability but I figured that it would be cool to try.

First of all, you will need an XMPP/Jabber IM client.  I used Trillian and it worked fine.

Next, sign up with this form

<FORM REMOVED>

This will provide an email address for you that you will copy and past into your instance of Zend Server.  Log in to your instance of Zend Server, or click on the link if you are in the DevCloud and go to Server Setup -> Monitor. For the mail server, enter in eschrade.com (because that’s where the notification messages will go), set whatever you want for the Sender Email Address and change the Monitor Rules Default Emails setting to the email address provided in the form above.

Now go to the Monitor settings under Rule Management.

Select all of the rules, or just the ones you want notifications for, select Email Emailing Action and click Change.  You may need to restart Zend Server.

After that you need to take your XMPP/Jabber client and connect it to my server.  Your credentials will be your [email protected], with the password you specified.

Now the next time an event occurs on your Zend Server or DevCloud system you should get a message in your IM like this.

Note that this is NOT an officially supported Zend service, I am just trying this out and wanted to offer it to others to see if they wanted to try it out too.

 

If you want to see how to set it up, here is a YouTube video of how it works.

How do you push your apps to the Zend Developer Cloud?

@mmd_coding posted a message about pushing a Yii app to the Zend Developer cloud.  I was asked by Roy Ganor if we knew how people were deploying and, quite honestly, I don’t know how people tend to.  Some of the options are

  • Zend Studio Deployment
  • Zend Studio RSE (SFTP)
  • Other IDE SFTP
  • Native SFTP

Which of these options do you use?

Please answer in the comment form.

URL rewriting in PHPCloud

Found out today that the typical rewrite rule

1
2
3
4
5
6
7
RewriteEngine On
 
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]

doesn’t work too well in the DevCloud.  I would get log errors like

[Tue Feb 07 13:06:33 2012] [error] [client 192.168.0.254] Request exceeded the limit of 10 internal redirects due to probable configuration error. Use ‘LimitInternalRecursion’ to increase the limit if necessary. Use ‘LogLevel debug’ to get a backtrace.

Turns out that the fix is really simple.

1
2
3
4
5
6
7
8
9
Options +FollowSymlinks
 
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteBase /
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]

Adding RewriteBase fixes the problem.

Looking for DevCloud stories

The Zend DevCloud was released at ZendCon as a technology preview.  I do a lot of my development work on the DevCloud now and I have my stories.  But I’m interested in hearing yours.  If you are using DevCloud for serious development work I would like to hear about it.  We would like to put together some examples of some cool work that people are doing on it.  So if you’d like a chance at getting some featured coverage on the DevCloud, please email me at [email protected] (no, I don’t care about spam any more) with some details.

If you do not have an invitation key, feel free to ping me at the same address and I’ll get you set up.

PHP Cloud and education

One of the problems that anyone who has taught a programming class will know is that the worst part of the class isn’t bored students, inane questions or poor material, but, rather, getting started.  I delivered Zend’s training for 3 years (myself among several others) and I can say, without reservation, that one of the most consistent impediments to the classes were getting things up and running.

Getting students to install stuff on their local desktops was often problematic.  They might have some conflicting software that would need to be removed (with the corresponding pulling of teeth).  There might be restrictions of what they could and could not install.  Or they might not have had the skills to set up a working environment on their local machine.  So we basically had to support any kind of scenario

To get around that issue we started creating VMWare instances.  Lots of them.  And it ain’t easy either.  You have to keep all of the OS instances up to date along with the IDE.  And once you’re done you need to zero out the free space to maximize compression to keep the VM’s from becoming quite large.

In short, managing coursework is not necessarily as straightforward as one might think.

If you’re in this predicament you might actually want to take a look at phpcloud.com. With the DevCloud what you can do is set up a container that has all of the example code, scripts and anything PHP in nature and take a snapshot of it.  That snapshot includes things like database content.  Students can then take that snapshot and create their own container out of it, without having to install new software, manage an environment that they may not be familiar with or do tasks that they don’t have the skills for.  You get the full PHP environment without any of the hassle plus some additional goodies for free that you’d normally have to pay for (like Zend Server).

So, if you’re doing any kind of training or class work and don’t like wasting time helping people get an environment up and running on a machine that you’re not familiar with, check out phpcloud.com.  It’s currently in a technology preview state but it’s pretty robust.  And the cost?  It’s free.  And we expect there to be a free tier as far into the future as we can see.  Check it out.

Here’s a video where I show how you can use snapshots.

Debug tunneling with the Zend DevCloud

Found out something interesting.  If you’ll notice there are no blog posts on how to debug PHP with the DevCloud.  That’s because while I can get it to work quite easily with Studio I was having a bear of a time getting it to work with anything else.  Since Studio worked I knew it was NOT the DevCloud’s fault, but had no idea what could be going on.  Turns out that the version of Putty that you have for setting up the tunneling matters.  If you have version 0.60, like I did, debug tunneling will not work even though DB tunneling does.  You need to have version 0.62 for debug tunneling to work

Connecting to the Zend Developer Cloud with PDT

A couple of weeks ago I wrote a series of blog posts on how to connect to the Zend Developer cloud with various IDEs.  Except one that I missed… PDT.

The deployment plugin is already installed in PDT 3 and so you already will have the ability to push to the DevCloud instance.

PDT, as opposed to Zend Studio, does not support the automatic remote server integration.  In other words, there will be a (simple) extra step.

First off, create your application the way you normally would.

Then associate your DevCloud account with your machine.  Go to the Targets view (a new view in the newest version of PDT) and click on the New Target button

Click the button and you will get the option for creating a new target.

Set your details

To push your application to your DevCloud instance simply drag the project to the appropriate target in the Targets window.  When you mouseup you will have a few options.  Choose Launch a PHP Application.

When you click on that item you will be presented with a box that allows you to specify the URL for that application.

When you click on Finish the application will deploy.  If the application has already been deployed to your DevCloud instance you may be asked if you would like to update it.  When the application is deployed it will also appear under the my.phpcloud.com UI.

If you change your application (i.e. do work) you will need to redeploy the application.  This is because PDT does not support the remote system integration like Zend Studio does.  So, to push your code to your DevCloud instance you need to open the deployment.xml file in the Deployment editor and click the “Deploy” button.

 

Superhero Antics

I’ve wondered.  What does a superhero do in their free time?  If you have an idea why don’t you take this transparent PNG

and put him in the middle of a few high jinks.  Post links to your images in the comments.

Connecting to the Zend Developer Cloud using NetBeans for PHP

Getting NetBeans connected to the Zend Developer Cloud is actually pretty simple…  if you have NetBeans 7.1 which is currently in RC.  NetBeans 7.0 has a bug that won’t allow you to connect to Git over HTTPS.  NetBeans 7.1 fixes that issue.  You will also need to make sure that you have the Git module installed.

Start by deploying one of the PHP applications from the DevCloud UI.

Then go to Team -> Git -> Clone and enter in your container details

Click Next and select the only branch available.

Click on Next and set up your local destination information.

Click on Finish and then you’ll get a dialog box like this

Make sure you think to yourself “why yes, I would like to create an IDE project from the cloned sources”.  Click on Create Project… and select PHP Application from Remote Server.

 

Click Next and then select the location where you want this project to be stored.  Select the version of PHP to be 5.3.

Click Next.  On the next screen you’ll need to set up a few things for the remote connection.  Click on Manage so you can set up the remote container.

The host name is the name of your container and the username is your container username.  Leave the password blank and instead select your private key for authentication.

The initial directory will take a little bit of work to find because you can’t browse for it.  Log in with an SFTP client using these same credentials and cd into the applications directory, which is actually a symbolic link.  In there navigate to the public document root and type ‘pwd’.  That will give you the deployment directory.

Click on OK which will bring you back to your remote configuration screen.

Enter in the project URL, which will also need to include the request URI for the application, select the remote connection and set the upload directory to the base directory.

Click on Next and NetBeans will then start to download all of the remote content onto your local machine.

Click on Finish and you’ll have your remote project on the DevCloud combined with the Git repository and you’re all set!

 

 

 

Web Analytics