Nette is a popular PHP framework that focuses on being lightweight and easy to learn. It provides a mature object-oriented design built on decoupled and reusable PHP components. Nette prides itself on its excellent performance, robust security features, and easy extensibility through community-written plugins.

Getting Started with AppFog

Before you can deploy anything to AppFog, you need to sign up for a CenturyLink Cloud account and enable AppFog for your account. To get a good understanding of AppFog, we recommend reading the Getting Started Guide. The following steps get you up and running quickly.

Enable AppFog

First, enable AppFog through the CenturyLink Cloud Control Portal.

  1. Go to the Control Portal and log in.
  2. Select AppFog from the pull-down menu. Control Portal
  3. Select a Region to host your application. Host Region

Log in to AppFog Using the Cloud Foundry Tools

Once AppFog is set up in your CenturyLink Cloud account, you need to login to AppFog using the Cloud Foundry CLI. The Control Portal gives you an exact command from the Overview tab.

  1. Find the cf login command on your AppFog Control Panel. It looks similar to the following:

        cf login -a -o C007 -u your.username

    Portal Login

  2. Run the command in your project directory.
  3. Enter your CenturyLink Cloud password when prompted. Password
  4. Select the Dev application space. Dev App

    Note: To learn more about logging into AppFog using the Cloud Foundry CLI, read this Knowledge Base article.

Getting the Nette QuickStart Application

This tutorial uses the Nette Sandbox application from the Nette QuickStart Guide. To get started, run the following command in your shell:

    $ composer create-project nette/sandbox nette-blog
    $ cd nette-blog

This downloads the Nette "sandbox" application into the nette-blog directory. That is going to be the project working directory for the rest of this tutorial.

Configuring the Nette Sandbox for AppFog

AppFog uses buildpacks to install and deploy services which run and support your application. For instance, the PHP buildpack used in this tutorial includes a specific version of PHP, a web server, and several support utilities. The PHP buildpack works closely with Composer to install project dependencies, which integrates conveniently with the PHP frameworks used in the tutorial.

Configuration for an AppFog project happens inside the project's working directory. Your working directory is the nette-blog directory you created in the previous step.

Creating a Project Manifest

In the working directory for the project, create a manifest.yaml file with a text editor and edit it to look like this:

     - name: <your-app-name>
       memory: 512M
       instances: 1

Replace <your-app-name> with a project or application name. The name can’t contain any spaces. Note that because AppFog uses a global project name space this needs to be unique across AppFog.

Configuring the PHP Buildpack

The PHP buildpack configuration is kept in a subdirectory of the project directory. This configuration allows you to specify PHP versions and configure different subsystems and services, such as Composer and Apache HTTPD. To configure the buildpack for your project, follow these steps:

  1. Inside the project working directory, create a .bp-config directory:

        $ mkdir .bp-config
  2. With a text editor, create and edit .bp-config/options.json to look like this:

          "PHP_VERSION": "PHP_55_LATEST",
          "COMPOSER_VENDOR_DIR": "vendor",
          "WEBDIR": "www",
          "PHP_EXTENSIONS": [ "bz2", "zlib", "openssl", "curl", "mcrypt", "mbstring", "pdo", "pdo_mysql" ]
  3. From the project working directory, run the following command:

        $ mkdir -p .bp-config/httpd/extra
  4. With a text editor, create and edit .bp-config/httpd/extra/httpd-modules.conf to look like this:

        LoadModule authz_core_module modules/
        LoadModule authz_host_module modules/
        LoadModule log_config_module modules/
        LoadModule env_module modules/
        LoadModule setenvif_module modules/
        LoadModule dir_module modules/
        LoadModule mime_module modules/
        LoadModule reqtimeout_module modules/
        LoadModule unixd_module modules/
        LoadModule mpm_event_module modules/
        LoadModule proxy_module modules/
        LoadModule proxy_fcgi_module modules/
        LoadModule remoteip_module modules/
        # Needed for PHP application framework
        LoadModule rewrite_module modules/
        LoadModule access_compat_module modules/

Configuring the Cloud Foundry CLI Tool

Since all application dependencies are handled by Composer, we can configure the Cloud Foundry CLI tool to exclude those from upload commands. This can save time and resources by significantly reducing the number of files uploaded by the tool. Configure the CLI tool by following these steps:

  1. In the project working directory, create and edit .cfignore to look like this:

  2. If your text editor uses different filenames for backups, temporary files, or lock files, add those patterns to the .cfignore file.

  3. If your application uses temporary files, installation-specific configuration files, or other files that don't need to be uploaded to AppFog, add those filenames or patterns to the .cfignore file.

Configuring Nette Sandbox Applications

Next, change the configuration of the Nette "adminer" sub-application so that you can connect to it later.

  1. Open www/adminer/index.php in a text editor.
  2. Edit the first block of code in the file to look like this:
        // if (isset($_SERVER['HTTP_X_FORWARDED_FOR']) || !isset($_SERVER['REMOTE_ADDR']) ||
        //     !in_array($_SERVER['REMOTE_ADDR'], array('', '::1')))
        if (false)
                header('HTTP/1.1 403 Forbidden');
                echo 'Adminer is available only from localhost';
                for ($i = 2e3; $i; $i--) echo substr(" \t\r\n", rand(0, 3), 1);

Configuring CenturyLink MySQL for the Nette Sandbox

Now upload your application for the first time and prepare a CenturyLink MySQL instance for it. Follow these steps:

  1. Upload your application without launching it by running these commands in your project directory.
        $ cf push --no-start
  2. Provision a MySQL instance and attach it to your application using the following commands:

        $ cf create-service ctl_mysql micro <your-database-name>
        $ cf bind-service <your-app-name> <your-database-name>
  3. Replace <your-database-name> and <your-app-name> with the name of your AppFog application and a database name.

  4. Find your MySQL configuration and authentication information using the cf env command.

        $ cf env <your-app-name>
         "VCAP_SERVICES": {
          "ctl_mysql": [
            "credentials": {
             "certificate": "-----BEGIN CERTIFICATE-----{...}-----END CERTIFICATE-----",
             "dbname": "{dbname}",
             "hostname": "{hostname}",
             "password": "{password}",
             "port": {port},
             "username": "{username}"
            "label": "ctl_mysql",
            "name": "<your-database-name>",
            "plan": "micro",
            "tags": []
  5. Record the dbname, hostname, password, port, and username to configure your Nette application. This information is needed later.

For more information on using CenturyLink MySQL with AppFog applications, read this Knowledge Base article.

Launching Your Nette Sandbox on AppFog

Now you are ready to deploy your Nette sandbox and run it in AppFog. Use the following command:

    $ cf push

If the command is successful, you should see output that ends like this: Success

Look for the line that starts urls:. In the screenshot, the URL is returned as This URL is needed in the next section.

The Nette Sandbox Welcome Page

In your web browser, visit the URL returned by the cf push command in the previous section. You will see a Congratulations! page powered by the Nette Sandbox.


We will now configure the Adminer database tool.

  1. Click on Manage database tables.
  2. In the Login section, fill out the dbname, Password, and Username values you saved from the Configuring CenturyLink MySQL for the Nette Sandbox section.
  3. In the box labeled Server, input the hostname and port separated by a colon. For example, if your hostname is and your port is 49211, you would input
  4. Click Login. You will now see the Nette Adminer database management tool.


    That's it. You're done!

Other Framework Resources

We have tutorials available for other popular frameworks. You might want to check them out as well.

What's Next?

These brief tutorials provides a thorough outline of what's needed to get an application written for a PHP framework to run on CenturyLink AppFog. Expanding on these tutorials, you can add CenturyLink Object Storage, Autoscale, and other robust cloud services to give your application the performance edge it needs. For more information and helpful tutorials you might want to check out the CenturyLink Cloud blog and our Knowledge Base.

Sign-up for our Developer-focused newsletter CODE. Designed hands-on by developers, for developers. Keep up to date on topics of interest: tutorials, tips and tricks, and community building events.

We’re a different kind of cloud provider – let us show you why.