Do you know phalcon ? It’s a PHP framework, not just one between all of them, it’s the fastest ever build.
So much speed is quite simple to understand, it works as a C-extension, but you don’t have to worry, all the functions are exposed as PHP classes.
So before going further, I will make a docker image so it will be easier to manipulate.
We need to install (under debian jessie):
- Apache 2.4
- Php 7.0
- Phalcon 3
The first step is to install apache and php, nothing difficult except the fact that php 7 is not in the debian repository, so I will use dotdeb. This is quick to add the repository:
1 2 |
echo 'deb http://packages.dotdeb.org jessie all' > /etc/apt/sources.list.d/dotdeb.list && wget https://www.dotdeb.org/dotdeb.gpg && apt-key add dotdeb.gpg && rm dotdeb.gpg<code striped="true" nums="true" lang="C"> |
Then it’s just some apt-get install with all the plugins needed as php7.0-pgsql.
The second step is to install phalcon on the image, I will use the github version. You just have to clone it, go in the directory:
1 2 3 |
git clone --depth=1 http://github.com/phalcon/cphalcon.git && cd cphalcon/build && ./install |
Now we have to tell php that we have phalcon, here it is:
1 2 3 |
echo 'extension=phalcon.so' > /etc/php/7.0/mods-available/phalcon.ini \ && echo 'extension=phalcon.so' > /etc/php/7.0/apache2/conf.d/50-phalcon.ini \ && echo 'extension=phalcon.so' > /etc/php/7.0/cli/conf.d/50-phalcon.ini |
We tell it for both apache configuration and the commad line interface (CLI).
By the way, you can look I set “50-XXXX”, it’s not some magic trick, if you just put “20-XXXX” then phalcon will be load at the same moment as the others php extensions, and using the CLI you will get:
1 |
PHP Fatal error: Class 'jsonserializable' not found in Unknown on line 0 |
So the number has to be more than 20, the choice of 50 is arbitrary.
So now we have an image able to run a phalcon project, but if you look the documentation of phalcon there are some great commands that exists.
To be able to use them we need the phalcon-devtools that is available on git, so:
1 2 3 4 5 |
git clone http://github.com/phalcon/phalcon-devtools.git && cd phalcon-devtools/ && . /home/phalcon/phalcon-devtools/phalcon.sh && ln -s /home/phalcon/phalcon-devtools/phalcon.php /usr/local/bin/phalcon && chmod +x /usr/local/bin/phalcon |
Now we get it all!
The Docker project is available on github or via the docker hub.
All the funny facts:
Debian is beautiful, but sometimes you are just not lucky:
1 |
Failed to fetch http://httpredir.debian.org/debian/pool/main/libf/libfile-fcntllock-perl/libfile-fcnt |
And of course it didn’t happen during a local build, but over the docker hub one!
And it’s not the end, when the build was finally a success, I tried on my mac, no problem. Later I did the same on my debian jessie server and BOUMMMMMM … not working.
Yes the container was running, apache and php too, I was able to load a php script like phpinfo() but when it was time to try phalcon I just had a crash. I was very suprised, so I looked to find source of the problem, and it came to that line:
1 |
$application->handle()->getContent(); |
I knew I was just screwed.
I tried to upgrade docker from 1.11 to 1.12, but nothing changed, so I opened an issue. We can still use it with a manual build as explained in the github README.
The next part will be a basic usage of the developer tools.
Vues : 5241