PaaS (platform as a service) is not a new concept. The fact of the matter is hosting companies have long since provided PaaS when they sell shared-hosting services that include PHP on the shared server. This is fundamentally different, however, from how a PaaS business works. In this article, we’ll take a look at a newcomer to the platform service provider arena – Fortrabbit – and set up a simple PHP/MySQL application that can be publicly accessed in a matter of minutes. Basic knowledge of the LAMP stack is assumed, and you also need to have a basic grasp of Git (if you don’t here’s a decent introduction), and you need to have SSH keys generated and ready for use (if you don’t, refer to this resource from GitHub). This walk-through is Unix oriented (so OS X and Linux users are fine), but it can also be applied to a Windows environment with minor changes.
Fortrabbit – the Who, Why, and How
Fortrabbit is a young PaaS company who say the hosting business is broken, and too much about price dumping and too little about quality. In order to fix the problem, they made a PHP-exclusive business that caters to developers’ most common needs. Their hosting plans are accessibly-tiered for everyone, from hobbyists (free plans) to enterprises (high-availability upgrades are available at the click of a button). With a single dashboard, you have an overview of all your applications, regardless of your role in them.![](https://uploads.sitepoint.com/wp-content/uploads/2013/01/Screenshot-from-2013-01-15-133725.png)
The demo app
Let’s get a simple Hello World application up and running. Clone the example repository from Github. It’s nothing but a simple CodeIgniter skeleton application, slightly modified for our purposes here. The controller reads the URL input to find an ID parameter, and if it finds none, it sets it to 1, otherwise, it uses the one provided. This ID parameter dictates which database row we fetch, and thus whether the output will print “Hello World” or “Hello Bruno”. See thedb
directory for the SQL import script create a database called “sitepoint”. Also, modify the database.php
file in the application/config
directory accordingly so your app can access the database. In my case, the username is root, and I have no password.
Test the application by creating a virtual host for it. For the sake of example, let’s assume you named the host fortrabbit.sitepoint.test. Thus, entering fortrabbit.sitepoint.test/ into your browser should say “Hello World!” and fortrabbit.sitepoint.test/welcome/index/id/2 should say “Hello Bruno!”. All good? Great! Let’s cloud it up.
Setting up a Fortrabbit Application
Go to Fortrabbit and sign up for an account. Once you have an account, proceed to click the New App button on the dashboard:![](https://uploads.sitepoint.com/wp-content/uploads/2013/01/Screenshot-from-2013-01-14-125250.png)
![](https://uploads.sitepoint.com/wp-content/uploads/2013/01/Screenshot-from-2013-01-14-134807.png)
![](https://uploads.sitepoint.com/wp-content/uploads/2013/01/Screenshot-from-2013-01-14-135755.png)
Dashboard
The app dashboard Fortrabbit takes you to after you click “Take me to my app” on the final configuration screen is where proper management takes place. Here you can see how much time you have until the app is frozen, and can reset the timer at will. All you do by doing that is prove your activity and the app stays alive, simple as that. The strength and cost of your app’s plan are defined here as well, along with some quick stats and a list of purchased add-ons (e.g. Memcache is an add-on you need to pay extra for).![](https://uploads.sitepoint.com/wp-content/uploads/2013/01/Screenshot-from-2013-01-14-141638.png)
Deploying
Fortrabbit, being young, still does’t have a web GUI for MySQL installed, so no PHPMyAdmin. You can, of course, install your own – but there’s another option that’s quite practical. MySQL Workbench supports remote tunnel connections via SSH, so assuming you have it installed (and you really should have it installed), open a new connection and define all the required parameters:![](https://uploads.sitepoint.com/wp-content/uploads/2013/01/Screenshot-from-2013-01-14-145552.png)
application/config/database.php
, we placed the following code (replace your username and password accordingly):
<!--?php <br ?-->if (isset($_SERVER['APP_NAME'])) {
// This means we're on Fortrabbit, and need different credentials.
// Local setups don't have the "APP_NAME" environment variable
$db['default']['hostname'] = 'sitepoint.mysql.eu1.frbit.com';
$db['default']['username'] = 'sitepoint';
$db['default']['password'] = 'xxxxxxxx';
}
This works because Fortrabbit defines an environment variable for every app called APP_NAME
which we don’t have on our local machine. Whenever we’re testing locally, our app accesses the local database as it did before. When we test online, the username, password, and host switch to the Fortrabbit credentials. Note that you can define an arbitrary amount of environment variables in the app’s dashboard under the PHP tab.
The next step is importing the SQL file into the database. With our connection to MySQL still open, import the provided SQL file from the db
folder.
Now let’s finally deploy our application. This is done in several steps and has multiple possible approaches; we’ll cover only one.
Step 1: Clone your current Fortrabbit app
In the terminal, entergit clone git@git1.eu1.frbit.com:sitepoint.git
which will clone an empty repository from your Fortrabbit app. It might be strange that the repo is empty when in fact you see some content when you visit the app’s URL, but this is because there’s a hidden index.php
file inside it already that’s initially ignored. As soon as you push the first commit, this index.php
file is overwritten (if you added such a file in the root of your project, that is).
Step 2: Add content to folder, add to Git
Next, we take the entire content of our local application and just move it into this directory. Then add the contents of the directory to the repository with the following command:git add *
, and of course, make a commit (git commit -am 'Initial commit'
)
Step 3: Push the app live
Use thegit push origin master
command to push your application live. The origin master
part is only required on first push – subsequent pushes do not require it.
Step 4: Change the domain setting
In the “Manage app” screen under the domains tab, addpublic
after the original URL in the input field, like so:
![](https://uploads.sitepoint.com/wp-content/uploads/2013/01/Screenshot-from-2013-01-14-180749.png)
public
, instead of the unavailable top folder.
That’s it! Visit your app now via its URL and you should see it work just as it does locally. Append the URL part with the parameters (/welcome/index/id/2) and see the string change. This shows us that both URL rewriting and the database connection work as they should.
Free Give Away
In a sea of *aaS services, Fortrabbit stands out with usability, simplicity, approachability and a heavily involved staff that are there for you every step of the way. In this generous and ambitious spirit, Fortrabbit is teaming up with SitePoint for an awesome give away! Five lucky readers will win coupon codes worth 100€ redeemable for Fortrabbit service. To be eligible, 1) try out Fortrabbit and post a comment below letting us know your experiences, or 2) follow @phpmasterdotcom and share this article on Twitter with the hashtag #phpmaster, all by February 20th. Five winners will be chosen at random shortly thereafter. Comment winners will be notified by email (be sure to provide a valid email address in the contact-form!) and Twitter winners by direct-message. Good luck!Frequently Asked Questions (FAQs) about PHP as a Service on Fortrabbit
What is PHP as a Service on Fortrabbit?
PHP as a Service on Fortrabbit is a cloud-based platform that allows developers to run, manage, and scale PHP applications. It provides a fully managed PHP environment, eliminating the need for server management and configuration. This allows developers to focus on writing code and developing applications, rather than managing infrastructure.
How does Fortrabbit compare to other PHP as a Service providers?
Fortrabbit stands out for its simplicity and ease of use. It offers a fully managed PHP environment, which means you don’t have to worry about server management or configuration. It also provides a range of tools and features to help you develop, deploy, and manage your PHP applications, including Git integration, SSH access, and automated backups.
Is Fortrabbit suitable for beginners?
Yes, Fortrabbit is designed to be user-friendly and accessible to developers of all skill levels. It provides a simple, intuitive interface and a range of tools and features to help you get started with PHP development. Plus, it offers comprehensive documentation and support to help you along the way.
How secure is Fortrabbit?
Fortrabbit takes security seriously. It provides a range of security features, including SSL encryption, two-factor authentication, and automated backups. Plus, it operates in compliance with EU data protection regulations, ensuring that your data is handled securely and responsibly.
Can I use Fortrabbit for free?
Fortrabbit offers a range of pricing plans to suit different needs and budgets. While it doesn’t offer a free plan, it does provide a trial period that allows you to test out its features and see if it’s the right fit for you.
How does Fortrabbit handle scaling?
Fortrabbit is designed to scale with your needs. It provides automatic scaling, which means your applications can handle increased traffic without any manual intervention. Plus, it offers a range of pricing plans that allow you to scale up or down as needed.
Can I use my own domain with Fortrabbit?
Yes, Fortrabbit allows you to use your own domain. It provides a simple, straightforward process for setting up your domain, and it offers comprehensive documentation to guide you through the process.
What kind of support does Fortrabbit offer?
Fortrabbit offers comprehensive support to its users. This includes detailed documentation, a community forum, and a dedicated support team that’s available to assist with any issues or questions.
Does Fortrabbit support other programming languages besides PHP?
Fortrabbit is primarily a PHP platform, but it does support other technologies that are commonly used in PHP development, such as MySQL, Git, and Composer.
How does Fortrabbit handle backups?
Fortrabbit provides automated backups to ensure that your data is safe and secure. You can also manually backup your data at any time, giving you complete control over your data.
Bruno is a blockchain developer and technical educator at the Web3 Foundation, the foundation that's building the next generation of the free people's internet. He runs two newsletters you should subscribe to if you're interested in Web3.0: Dot Leap covers ecosystem and tech development of Web3, and NFT Review covers the evolution of the non-fungible token (digital collectibles) ecosystem inside this emerging new web. His current passion project is RMRK.app, the most advanced NFT system in the world, which allows NFTs to own other NFTs, NFTs to react to emotion, NFTs to be governed democratically, and NFTs to be multiple things at once.