Install Phalcon 3
Looking for sPHPeed? Phalcon is a web framework delivered as C extension providing high performance and low resource consumption. Here you learn how to best getting started with Phalcon 3 on fortrabbit.
Get ready
We assume you've already created an App with fortrabbit. You should also have a PHP development environment running on your local machine. You can skip the following two parts when you have chosen Phalcon in the Software Preset when creating your App.
Root path
Go to the Dashboard and set the root path of your App's domains to public.
Phalcon extension
In the Dashboard with your App: enable the phalcon PHP extension.
Quick start
Install it locally
Phalcon is unlike any other framework. You first need to get Phalcon running locally. That's the hard part:
- Install the C-extension
- Download the Phalcon developer tools
- Create a Phalcon project
- Check the installation
Deploy to fortrabbit
Once that gives you a green light, continue by executing the following in your local terminal to start from scratch with a fresh new Phalcon installation on fortrabbit:
# 1. Create a local folder called like your App
$ mkdir {{app-name}}
# 2. Change into that folder
$ cd {{app-name}}
# 3. Initialize local Git repo
$ git init .
# 4. Make sure to keep the cache folder in Git
$ touch cache/.gitkeep
# 5. Add all files
$ git add -A
# 6. Commit files for the first time
$ git commit -m 'Initial'
# 7. Add fortrabbit as a remote
$ git remote add fortrabbit {{ssh-user}}@deploy.{{region}}.frbit.com:{{app-name}}.git
# 8. Initial push and upstream
$ git push -u fortrabbit main
# 9. From there on only
$ git push
When it is done you can visit your App URL in the browser to see the Phalcon welcome screen:
Advanced setup and migration
Until now this is a very vanilla Phalcon. Now, make it yours.
Creating a project
Now you might want some stuff to happen there. See official guides to get started with a Phalcon project.
MySQL
Use App environment variables to attain database login details at runtime. Open configuration file app/config/config.php
and modify it directly after the defined
statements like so:
// ^^^ defined statements
return new \Phalcon\Config([
'database' => [
'adapter' => 'Mysql',
'host' => getenv('MYSQL_HOST') ?: 'localhost',
'username' => getenv('MYSQL_USER') ?: 'your-local-db-user',
'password' => getenv('MYSQL_PASSWORD') ?: 'your-local-db-password',
'dbname' => getenv('MYSQL_DATABASE') ?: 'your-local-db-name',
'charset' => 'utf8'
],
'application' => [
// do not change these contents
]
]);
MySQL access from local
Please see the MySQL article on how to access the database remotely from your computer.
Updating Phalcon on fortrabbit
There might be a new version of the Phalcon extension available. At a certain point when software versions are becoming outdated (EoL) we will force these updates. We recommend to that before to leverage new features and improved speed.
Within the fortrabbit Dashboard: Go to the PHP Settings of your App. Check if it uses the latest PHP version and also enable the latest Phalcon version.
- Phalcon2 is available for PHP 5.X and PHP 7.X
- Phalcon3 is available for PHP 7.X