PHP Fog Blog

Using Symfony2 on PHP Fog Right Now

This is another post in our series of guest posts about using PHP Fog. The original post by @developly is reprinted here with permission.

 

PHP Fog is a new PHP PaaS service. It’s dazzling. It takes the weight of deploying applications to the cloud off your shoulders and allows you to focus on writing code. You can deploy your app’s with a simple git push phpfog master. This is great, but PHP Fog is new and there is no built-in considerations for Symfony2. That makes sense – Symfony2 is still (at the time of writing) in beta. But I want to deploy Symfony2 apps now!

In this article I’ll show you how you can use PHP Fog to host a Symfony2 application. For the purpose of ease we are going to use Github but you could just as easily host your code with Beanstalk, or use PHP Fog’s Git repository alone.

Step 1, setup a Symfony2 app in Git.

If you already have your application in Git and have at least one production route, then you can skip to the next step.

  1. Download the Symfony2 Standard Edition
  2. Add a new bundle called CompanyExampleBundle where company is the name of your company, group, or project. Don’t forget to add Company to the auto-loader inapp/autoload.php, and register the bundle in app/AppKernel.php.
  3. Create a new controller at src/Company/Controller/HelloWorldController.php which renders a view CompanyExample:HelloWorld:index.html.twig. In the view, put in a nice little Hello world!.
  4. In app/routing_dev.yml change the _welcome route’s pattern to /welcome. Now go toapp/routing.yml and add a route like so:
  5. At this point, verify that you can get to the new controller by traveling to  http://localhost/yourproject/web/app_dev.php/ in your browser. If you see a Hello world!, then you’re gravy. Now substitute app_dev.php for just app.php to access the production front controller and make sure you see the same thing. If you get a 400 or things appear to be as they were before, you might need to blow production cache. This can be done from the command line like so:
  6. You’ve setup a new Symfony2 app and are ready to get going! Commit and push your application to Github then continue on to the next step.

Step 2, Create your app on PHP Fog.

  1. Login to PHP Fog and select Create a New App.
  2. On Step 1 of the application wizard choose “Custom App” from the bottom left.
  3. On Step 2 it’s important to note that if you want to use Assetic, then you need a paying box – this is because the shared tier does not support open_basedir. If you aren’t going to use Assetic, go ahead and choose the free shared tier.
  4. On the final step choose a URL. If you decide to use a custom URL you will have to alter DNS settings, so for a quicker finish we’d suggest a phpfog url. Once you’ve done this hit the “Create Application” button and you’re done! Once the application has been provisioned you will receive an email and can continue onto the next step.

Step 3, Pushing your Symfony2 application to PHP Fog

Pushing your app to PHP Fog is really easy. It’s perhaps my favorite thing to do.

  1. Add the public key from the machine you are working on ~/.ssh/id_rsa.pub to the accepted SSH keys in your Account Settings.
  2. Now go to the Source Code tab from your apps PHP Fog admin panel and copy the git repository location.
  3. Finally, from the console, add phpfog as a remote and push. Like so:
  4. Now test that your code made it up by accessing the robots.txt file that comes with Symfony2 by default. Should be at a url like so:http://company.phpfogapp.com/web/robots.txt. If this resolves, you’ve successfully deployed your code to the cloud!

You’re not done yet, however, you still need to tweak you PhpFog app to Symfony2’s liking.

Step 4, Configure your PHP Fog app for Symfony2

You’re almost there. There’s just a couple things left…

  1. Symfony2 caches all your configuration files to the app directory, and therefor needs write access. Go to the “Permissions” tab of your app’s admin panel and add the pathname app and save changes.
  2. Go to the “Settings” tab and change the Base Directory to web. This will tidy up your url, you won’t have to type in /web before accessing resources.
  3. Finally, you need a way to clear production cache, while in production. PHP Fog doesn’t give console access so the simplest way to accomplish this is by creating a php script called web/clean_prod_cache.php with the code like so:
  • Now when you go to http://company.phpfogapp.com/clean_prod_cache.php the cache will be wiped and warmed. All ready to go.

I hope that this guide helps both developers looking to use Symfony2 on PHP Fog early as well as the PHP Fog team in implementing Symfony2 support.

Developer Profile: Zachary Queal

This is the first in a series of interview style profiles we will be doing to showcase the developers using PHP Fog and AppFog.

So, tell me a little about yourself. Where are you from, how did you get into being a developer, and what are you doing for a living these days?

Well my name is Zach Queal, and currently I’m a resident of Long Island, NY. I’m from a very small town called Mansfield, Pennsylvania with, as you might be able to guess, not much to do! I’ve always had an affinity for technology and was introduced to programming, strangely enough, through my older brother who was required to take a course in HTML for school. What really sparked my attention was the ability to embed media into a page and have people from all over the world view it! After I conquered HTML, it was off to CSS, PHP, and JavaScript moving in an ever expanding outward ripple.

That’s cool to hear that you started so young! So, you’re a solo consultant. Do you enjoy that? Any advice for other developers thinking about going solo freelance?

No! It’s horrible, but I really enjoy working in medium to large teams with compelling individuals! The money’s not bad either! However I love the concept of owning my own business; even the ability to be able to make or break it strictly on my own ability. It’s an indescribable feeling.

Yeah, I can see it being a mixed bag – it’s a tough thing running your own business! You’ve been doing web development for a while. What got you into it? What kind of stuff do you like doing – and want to do – with web dev?

As I stated before I was introduced to programming at a very young age (~9-10) and it was something that I was good at, which really at the time I didn’t have a lot of things that I could do well! But I do enjoy helping large groups or corporations / non-profits with projects from website redesign to total inter-office upgrades. But what I really enjoy doing is helping other people with difficult problems. That’s all programmers are in my mind, people who enjoy solving other’s intricate problems. haha.

So true! How did you end up using PHP Fog and what attracted you to it in the first place? Was PHP Fog your first PaaS?

It was actually interesting for me because at the time, even though I pride myself on staying current with technology, I had never heard of platform as a service (PaaS). I was technically searching for an architecture or process that I could use to deploy applications very quickly with as little downtime as possible. I had recently been introduced to Git deployment from a friend and was researching a way to have my deployments automatically pushed to a web-viewable
directory when I happened to come across PHP Fog through a Google search. It was love at first push! Since that time I’ve been using PHP Fog (and now AppFog) for most of my projects from the fun ones to my corporate contracts.

Git really is the shit isn’t it? So now that you’re using PHP Fog – what are the killer features of the product and of PaaS in general?

PaaS, I think, is really a game changer in the web programming world. Not only does it incorporate the cloud which is basically the web revitalized for a new generation of computing and service deployment, but it also has many outlets for advancing many static application platforms. Not to mention the entire idea of PaaS really takes a lot of the scary out of being a newbie programmer, which hopefully will bring a lot to the game in future years. PHP Fog and AppFog really take expectation to the next level with easy to use web service layer, on top of a rock solid foundation with the application stack and variety of jumpstarts and every single add-on that you could ever need! Paired with the ability to scale, add load balancers, and even manipulate the cache of your applications is necessary and simply a joy using the system in place. But I think one of my favorite features by far is the ability to seamlessly incorporate strong SSL with a dedicated ELB and E.IP. I really believe that in this day and age security is not taken seriously enough, and it’s nice to know that I can provide this security to my clients for a very reasonable price!

I don’t think a lot of people see that link between the old web dev and the new cloud dev. It’s smart. What do you use PHP Fog for?

My very first experience with PHP Fog was deploying my personal resume to the cloud using the regular git push method. (not the pf command line application). I remember how easy it was to start with one of my all time favorite PHP Jumpstarts (Slim) and be ready to go after I took a quick minute to map out a design in my head. It was honestly addictive considering the best method I had before was to create a virtual instance on my dedicated server in Apache and using DNS and htaccess to map to the TLD.

You’re starting to look at the AppFog private beta now. Why?

After using PHP Fog for a few months, and all of the noise about AppFog had started flying around I was more than ecstatic! I couldn’t wait to try it. One of the turn-ons for me was the ability to launch anything from Python, to Ruby and Java applications in the cloud pretty much the same way I did with my PHP applications at PHP Fog. I truly love the fact that AppFog contributes comprehensive PHP support to a great open source project such as Cloud Foundry, as well as incorporates the ability to use other backbone services such as AWS, RackSpace, and even Joyent. I’ve been able to assuage many-a-client to use AppFog’s services simply because of the ability to use other highly dependable services from these recognized providers.

It’s awesome that clients see the value of infrastructure independence! Tell me about your experiences with AppFog the company.

As with many other Geeks, I have strict attention to detail, and need answers NOW! It’s what makes me tick, and what makes my business a success. The only time I’ve every had to submit a support ticket to PHP Fog support, it was responded to in less than 5 minutes and was resolved within 10. Having a company respond as professionally and accurately as that in such a short amount of time is reason enough to give anyone a 5-star rating.

As you can imagine, we LOVE that kind of feedback! What would you like to see from AppFog in the future?

Honestly there isn’t much I can say about this one! The reason why I continue to use PHP Fog is because it works for me, nothing more nothing less. Just about the only helpful suggestion that I could give here is that I would love to see the ability to add SSH keys to groups for easy record keeping. As of right now I have about 15 different SSH keys associated with a single account, as well as the ability to add application specific SSH key access. Thinking back, I
think that’s the only feature that PHP Fog is missing.

Coolness! What’s next for you?

I’d love to be able to say that I’ll finally grow up, become a successful programmer, and eventually the next Bill Gates; but who knows! As for right now, I’m content doing what I’m doing, which is more than I could ask for.

That’s awesome! Glad to hear it’s going so well for you.

Would you like to be featured in a future developer profile? Just let us know!

WHMCS on PHP Fog with MailGun (Pt II)

This post is the second part in a series of posts by Steven Eksteen (republished from his blog with big thanks to Steven). 

You should read the first post in the series before reading this one, of course.

So here we’ll hook up mail to WHMCS on PHP Fog using MailGun. After seeing the MailGun interface, if you haven’t before, you’ll be like Grate Monkey what? I was.

This is the part when you should read the last WHMCS & PHP Fog Article, if you haven’t already.

So if you know what PHP Fog is I assume you know your way around the interface. So once you’ve enabled the MailGun Addon you’ll get some pretty convenient Environment Variables. This is the quickest way to your SMTP details:

So I took these…

… and put them here (in WHMCS)…

Yes that’s right. I blurred some stuff out of the email address. Just because my little testing WHMCS can’t afford to send money to Nigerian Princes, doesn’t mean they’re going to stop emailing and asking.

Yay, you have outbound mail. The inbound mail is just as easy.

In PHP Fog, under Addons, click manage MailGun and you’ll get to the MailGun admin interface.

Here you can add mailboxes for all your WHMCS departments…


… and then create your WHMCS departments with those settings…

You’ll also notice this…

You will have to add that second line to a cronjob like in the previous article.

The End

Donations accepted in beer ONLY! :)

Installing ThinkUp on PHP Fog

Here at AppFog we’re always looking for awesome projects and products to add to our PHP Fog Jumpstart program.

One of our current favorite Jumpstarts is ThinkUp – and from what we’re seeing from you, our users, you also feel like ThinkUp kicks ass. It makes the job of managing your social media activity so much easier.

To our delight, the amazing Andy Baio created a very cool screencast showing how to install ThinkUp on PHP Fog.

So, in case you’re looking for an amazing free, open source web application for tracking, analyzing and managing activities on your social networks (Twitter, Facebook and Google+), watch this – and check out ThinkUp. We think you’ll be pleased.

Big thanks to Andy and the ThinkUp crew for doing this!

Share Your Code, Get Some Cash: Introducing Our Jumpstarts Program

For those who many not have heard, Jumpstarts are pre-configured packages for popular web frameworks and applications, from WordPress to Zend, designed to work for developers out of the box. When using PHP Fog, you simply select the jumpstart you’d like to use and just a few clicks away you’ll find the code available to modify to your heart’s content in your Git repository.

We’re proud of our jumpstarts offering, but we know it could be even better. If you have an open source project or an awesome product that you think our customers would love to use, we want to hear from you! We’d like to give you the opportunity to share your work with the tens of thousands of developers currently using PHP Fog, and we’re also looking to send some cash your way.

Welcome to our new Jumpstarts Program…

To get started you simply email jumpstarts@appfog.com. Tell us about your application (framework? application? use cases?), point us to the repo (we do love us some Git), and we’ll start talking.

Once your code is live as a Jumpstart, you get all the following cool stuff…

  1. One-click jumpstart support for your app/framework
  2. Landing page at http://phpfog.com/<jumpstart> where you can provide us with content to market your work
  3. Your jumpstart will be available to all PHP Fog customers during app creation
  4. You can, if you want to, become part of our referral partner program (with rev sharing – nice!)
  5. We give you free hosting for your project site on PHP Fog (or AppFog)
  6. We do co-marketing with you (buzz time baby!)
  7. You’ll get access to an API to provision apps for your customers (coming soon)
  8. And you get a “Try on PHP Fog” button to add to your site (coming soon)

So… let’s see if we’ve got this right… You can sign up to be a Jumpstart, get free hosting, get paid money when people you refer become customers, it costs you nothing, and you get access to tens of thousands of developers who now can easily develop apps using your project…

We’re really excited to see what you all do with this!

A Closer Look at the PHP Fog Facebook Jumpstart

From the desk of John-Michael Glenn, Software Engineer

In case you’re unfamiliar with the term “Jumpstart”, it’s our one-click method of creating a new app or framework in the PHP Fog cloud. The type of app or framework is up to you, from well-known projects like WordPress to newer frameworks like Slim. We love these little things because they make our users’ lives easier. Of course, you’re always able to use PHP Fog to run your own creations by creating a “Custom App,” but using one of our Jumpstarts makes the process of creating new apps far easier than anywhere else on the web, enabling developers to rapidly prototype a wide variety of applications.

Recently we introduced our latest Jumpstart: Facebook. No, I don’t mean all of Facebook in a single app, I mean a Facebook App. With this small framework, you can easily authenticate Facebook users, post to their walls, send email to users and more by using our wrappers for their API. We also included a bunch of images for everyone to use to give it more of that genuine Facebook App feel.

So, just how easy is it to create a new app in the PHP Fog cloud? Easy! Just follow these steps:

  1. Log into your PHP Fog account in a new tab/window.
  2. Click the “New App” button in the Shared Cloud area.
  3. Screenshot of the PHP Fog administrative console showing the button to create a new app

  4. Click the Facebook Jumpstart icon, taking you down the page.
  5. Screenshot of PHP Fog's Facebook application jumpstart icon

  6. Open a new tab/window and log into https://developers.facebook.com/apps, which will ask for your password to verify your identity.
  7. Click the “+ Create New App” button, then fill in the desired App name and hit “Continue”.
  8. Now you will be presented with your app information, along with your Facebook App ID and Secret Key. Copy your App ID and Secret Key (or write it down) and navigate back to your PHP Fog tab/window and fill in the fields as labeled, then click “Create App”.
  9. Screenshot showing sample PHP Fog Facebook application key & secret
    Screenshot of PHP Fog administrative console showing sample Facebook application details

  10. Now, while we set up your app in our cloud, take the URL that you typed into the “Domain” field (see image above), navigate back to your Facebook tab/window, and paste/type it into the “App Domain” field.
  11. Screenshot of application domain information required by Facebook to create an application

  12. Time to set up how your app integrates with Facebook’s offerings. The most basic way is to use Facebook to log into your app’s website. To do this, click the “Website” integration option and put your app’s URL in the “Site URL” field.
  13. Screenshot showing how to provide information to Facebook so that Facebook can be used to login to a PHP Fog app

  14. Finally, click the “Save Changes” button, and you’re done! To test it out go back to your PHP Fog tab/window and click the “View Live Site” button, which will redirect you to Facebook to allow the app to see your personal information, etc. To allow it access, click the “Go to App” button and see your sweet new Facebook App!

Screenshot showing a Facebook app running on PHP Fog cloud

That’s it! Now you’re free to explore the Facebook API as much as you like and tweak your app settings in the Facebook app console.

So while our Facebook Jumpstart is incredibly cool, we’re even more proud of the fact that we open sourced the code for it: https://github.com/phpfog/phpfog-facebook

Anybody can fork this code and submit pull requests for us to review and merge into our official Facebook App repo. We’re excited for members of the community to help make this jumpstart better for each other, and we’ve already had a pull request submitted and merged. Many thanks to Jim Carter III for adding URL redirect support to our Jumpstart. (Awesome Fog swag shall be thine!) We’re also excited to report that our repo already has 6 forks and 15 people watching it, all without us yet mentioning that the code is out there for you to experiment with and improve.

We hope even more folks find the code and our Facebook Jumpstart useful. Let us know what you’re building – I’m @phyre5 on Twitter, or you can just leave a note in the comments section.

Announcing the PHP Fog Command Line Interface Tool

We’ve heard from direct customer feedback and via our NPS surveys that our customers love PHP Fog, but setting up their SSH keys can be cumbersome. We want you to deploy your apps with velocity and grace, so we’ve released a new tool for PHP Fog: the PHP Fog Command Line Interface (PF CLI). The PF CLI is a command line tool for managing PHP Fog apps from the console.

The tool allows users to list and view app details, manage ssh keys, and easily clone and deploy apps. Additionally, the PF CLI does more advanced operations such as setting up ssh keys for multiple PHP Fog accounts and deploying apps using git submodules. PF CLI is provided for both experienced users and new users who need help getting started with PHP Fog.

photograph of Tim Santeford and Rich Howard

Tim Santeford and Rich Howard

The PF CLI has been a labor of love by Tim Santeford from our developer team and Richard Howard, from our support engineering team. Initially, the motivation behind creating this tool was to streamline daily and batch repetitive tasks for our own developer team. Once the first prototype was finished it was apparent that the tool would also be useful for our users. When the PF CLI is installed on our users machines it also gives our support team an additional tool for helping users. Our primary goal is to make it easy for customers to configure their machines and get up and running quickly.

You can learn more about the PF CLI in this post, or you can skip straight to our technical documentation and dig into our latest PHP Fog offering. But we think you’ll really enjoy the walkthrough Tim put together for you, so check it out!

Why Use the PF CLI

Along with the app management features, the PF CLI tool provides two functions that are difficult to perform without it. First, it configures a user’s ssh configuration for use with multiple accounts, allowing developers to work under multiple client logins. Second, it facilitates the fetching and deployment of git submodule dependencies. This feature allows users to continue to use git submodules with their master branch.

You may recall that we deprecated support for git sumbodules through our main interface, and we recommend using Composer for package management instead. However, we understand that some of our users prefer to use git sumbodules. With the PF CLI tool, you now have the choice of continuing to use use git submodules if you would like to do so.

Walkthrough

Here’s how to get up and running with the PF CLI:

Installation

$ curl -s https://raw.github.com/phpfog/pf/master/bin/installer | php

Run the setup

$ pf setup

List your apps

$ pf list apps

Fetch your app

$ pf clone

For even more details, check out our overview documentation on the PF CLI  and our how to guide, Getting Started Using PF CLI.

We look forward to your feedback on how using the PF CLI tool makes your life as a PHP Fog user better and your development process faster and graceful. Leave us feedback in the comments section of this post, or ping us on Twitter.

WHMCS on PHP Fog

We love the opportunity to share our customers successes using PHP Fog, and it’s even better when we can share what they’ve built and what they’ve learned using our platform. Today, we’re bringing you a How-To article on getting started with WHMCS – an all-in-one client management, billing & support solution for online businesses – on PHP Fog. This post comes in courtesy of our customer Steven Eksteen, who kindly allowed us to republish his work. Steven shows us how to get WHMCS up and running on PHP Fog and how to add cron support to the app.

Image of the PHP Fog Logo

Well, this is how I did it…

PHP Fog makes me almost like PHP again or rather like working with PHP. Managing infrastructure is, for me at least, like sitting in a room full of Man United fans after they have just won a game, painful. Maybe PaaS has just made me lazy.

With WHMCS & PHP Fog you can get going for about $16 for WHMCS & $30 for PHP Fog Per Month. You could use PHP Fog’s free shared cloud for testing.

I’ve created my app…

Before cloning your assigned git repo and while you’re still on the PHP Fog interface, just add the WHMCS permissions quick. Like so…

Screen shot of the PHP Fog Web Console Write Permissions section

You can now clone your repo.

Once you have a local copy delete the “index.php” and copy the WHMCS files in.

Rename the “configuration.php.new” file to “configuration.php”. Yes, it’s supposed to be a blank file.

You can now go ahead and send the files to your app…

$ git .

$ git commit -am “Fresh WHMCS install files”

$ git push origin master

You will now need your MySQL settings that PHP Fog created for you with your app

Screen shot of setting up database instance via the PHP Fog Web Console

You can now just goto your app URL and install WHMCS like normal.

Once installed you will be prompted to delete the install directory. You can delete or rename it, it doesn’t matter.

Done? Then you will need to make sure your blank “configuration.php” file does not overwrite your configured on on the server.

$ touch .gitignore

$ vi .gitignore

You can then add configuration.php to the file and save. My file looks like this

.DS_Store*
ehthumbs.db
Icon?
Thumbs.db
*.sublime-project
*.sublime-workspace
configuration.php

You will then have to tell git to stop tracking the configuration.php file, and the others

$ git rm —cached configuration.php

You can now push again to remove/rename the install directory on the server

$ git add .

$ git commit -am “Rename install directory”

$ git push origin master

-

The local copy

The following is not at all a requirement. I just find it most helpful.

Since the “configuration.php” in you local copy is still blank. You could rename the install directory back to install, or copy it in again and run a local WHMCS install. Just don’t push your changes until you’re done and removed/renamed the install directory again.

With a working local copy of WHMCS you can create your templates and modules and just push your repo to send then to the server having tested them first instead of doing it blind. Remember, there is no FTP access to your files so you will have to use git to push and pull files.

In his follow on post, Steven shares how to add cron support for his WHMCS app….

As per the PHP Fog documentation cron jobs can be done using two providers:

https://mywebcron-com.loopiasecure.com/
http://www.easycron.com/

The latter didn’t load for me, probably just my fantastic internet connection.

So I went and got an account at mywebcron-com.loopiasecure.com. Fantastically simple signup, just linked it to my Google account (but they have other linking options too).

The system is really everything you need. Nothing flashy, it works and it’s free.

So…

WHMCS’s “cron.php” is located at “WHMCSROOT/admin/cron.php”. So the URL would be like “http://app.phpfog.com/admin/cron.php” and set it to run once a day.

Screen shot showing set up of cron support for WHMCS

…and you’re done.

Many thanks to Steven for sharing his knowledge with us. We’re always excited to see your How Tos and articles on PHP Fog. Drop us a line and tell us what you’re learning!

Get $29 account credit by just deploying a new App!

For 72 hours we want to make it easier for you to try out our platform. If you deploy a new app to PHP Fog we’ll give you $29 in credit for your account.

That’s right – you deploy your app to PHP Fog, you get $29. That is one FREE month of professional grade dedicated hosting on our Silver plan. All you have to do is visit phpfog.com/promo, login or sign up, then deploy your app.

Photo of a happy developer using PHP Fog

“What kind of app can I create” you ask?

Try our brand new Facebook Jumpstart to deploy a Facebook app faster than you have ever been able to before. Better yet, check out all the source code for our Facebook Jumpstart and fork it on Github.

Screenshot of PHP Fog's Github Repository for its Facebook Jumpstart

Heard of ThinkUp, the new social network aggregating service? You can try it in seconds using our jumpstart. Or you can deploy a WordPress site, a Drupal site, a MediaWiki instance, fire up CodeIgniter, and more – we’ve got nearly 20  pre-configured packages for popular web frameworks and applications, designed to work for you out of the box.

The action starts at 8 AM PST on 6 March 2012 and runs until 8 AM PST on 9 March 2012. Visit phpfog.com/promo to get started. If you already have a PHP Fog account all you have to do is deploy a new app to one of your existing clouds. If you don’t have a PHP Fog account, just sign up for one and deploy your app!

Limit one $29 credit per customer.

Your $29 will be provided in account credit. Use it towards your current dedicated cloud or upgrade to one. You can even upgrade to Gold or Platinum and apply this against your cost! It’s your choice what you do with your credit. Full details at phpfog.com/promo.

As always, we love to know what you’re building. Tweet to us @phpfog and let us know what cool stuff you’ve created!

Powered by Olark