Nanobox is a portable, micro platform for developing and deploying apps. When working locally, Nanobox uses Docker to spin up and configure a virtual development environment configured to your specific needs. When you’re ready to deploy to live servers, Nanobox will take that same environment and spin it up on your cloud provider of choice, where you can then manage and scale your app through the Nanobox dashboard.

In this post, we’ll walk through getting a brand new Phalcon app up and running locally, with nothing installed other than Nanobox. First create a free Nanobox account, then download and run the Nanobox installer.

Create a New Project

Create a project folder and cd into it:

mkdir nanobox-phalcon && cd nanobox-phalcon

Add a boxfile.yml

Nanobox uses the boxfile.yml to build and configure your app’s runtime and environment. In the root of your project, create a boxfile.yml with the following:

  engine: php
    runtime: php-7.2
    document_root: public
      - phalcon
    - echo "alias phalcon=\'phalcon.php\'" >> /data/var/home/gonano/.bashrc

This tells Nanobox to:

  • Utilizar el motor de PHP, un conjunto de scripts que crean el tiempo de ejecución de la aplicación.
  • Utilizar PHP 7.1.
  • Establezca la raíz de documento de Apache en public.
  • Incluir la extensión de Phalcon. Nanobox adopta un enfoque básico para extensiones, así que es probable que necesite incluir otras extensiones. Puede encontrar más información aquí.
  • Agregar un alias al bash para Phalcon Devtools por lo que se puede usar el comando phalcon.

Add Phalcon Devtools to your composer.json

Create a composer.json file in the root of your project and add the phalcon/devtools package to your dev requirements:

    "require-dev": {
        "phalcon/devtools": "~3.0.3"

NOTE: The version of Phalcon Devtools depends on which PHP version you’re using.

Start Nanobox and Generate a New Phalcon App

From the root of your project, run the following commands to start Nanobox and generate a new Phalcon app. As Nanobox starts, the PHP engine will automatically install and enable the Phalcon extension, run a composer install which will install Phalcon Devtools, then drop you into an interactive console inside the virtual environment. Your working directory is mounted into the /app directory in the VM, so as changes are made, they will be reflected both in the VM and in your local working directory.

# iniciar nanobox e ingresar a la consola
nanobox run

# cambiar al directorio /tmp
cd /tmp

# generar una nueva aplicación Phalcon
phalcon project myapp

# cambiar al directorio /app
cd -

# copiar la aplicación generada al proyecto
cp -a /tmp/myapp/* .

# salir de la consola

Run the App Locally

Before actually running your new Phalcon app, we recommend using Nanobox to add a DNS alias. This will add an entry to your local hosts file pointing to your dev environment and provide a convenient way to access your app from a browser.

nanobox dns add local

Nanobox provides a php-server helper script that starts both Apache (or Nginx depending on your boxfile.yml config) and PHP. When passed with the nanobox run command, it will start the local dev environment and immediately run your app.

nanobox run php-server

Once running, you can visit your app at

Check Out the Environment

Your virtual environment includes everything you need to run your Phalcon app. Feel free to poke around.

# ingresar a una consola Nanobox
nanobox run

# comprobar la versión de PHP
php -v

# comprobar la versión disponible de Phalcon Devtools
phalcon info

# Comprobar que tú código base esté montado

# salir de la consola

Phalcon and Nanobox

Nanobox gives you everything you need develop and run your Phalcon app in an isolated virtual environment. With the boxfile.yml in your project, collaborators can get up and running in minutes simply by running nanobox run.

Nanobox has a Phalcon Quickstart that includes everything covered in this post. They also have as guides for using Phalcon with Nanobox. In future posts, we’d like to cover other aspects of using Phalcon with Nanobox, including adding and connecting to a database, deploying Phalcon into production, etc. If you’re interested let us know on Twitter.