Blog and News

Hello community!!

We are releasing Phalcon 3.2.1 today, addressing several bugs.

Release

The release tag can be found here: 3.2.1. The Windows DLLs are in the releases Github page.

Changelog

  • Added Phalcon\Db\Dialect\Mysql::getForeignKeyChecks to generate a SQL to check the foreign key settings #2604, phalcon/phalcon-devtools#556
  • Fixed inconsistent behaviour of Phalcon\Config::merge across minor version of PHP7 #12779
  • Fixed visibility of Phalcon\Mvc\Model\Query\Builder methods: _conditionNotIn, _conditionIn, _conditionNotBetween and _conditionBetween to allow 3rd party libraries extend it
  • Fixed Phalcon\Assets\Manager::output, implemented missing resource type filtering for mixed resource collections #2408
  • Fixed Phalcon\Http\Response::getStatusCode to return (int) HTTP code only, instead of full string #12895
  • Fixed Phalcon\Db\Dialect\Postgresql::addForeignKey for proper creating the foreign key without a name
  • Fixed Phalcon\Cache\Backend\Apcu::flush to use APCu instead APC #12934
  • Fixed Phalcon\Db\Adapter\Pdo\Mysql::addForeignKey for proper creating the foreign key with a desired key name #2604, phalcon/phalcon-devtools#556
  • Fixed Phalcon\Db\Dialect\Mysql::addForeignKey to generate correct SQL #2604, phalcon/phalcon-devtools#556

Update/Upgrade

Phalcon 3.2.1 can be installed from the master branch, if you don't have Zephir installed follow these instructions:

git clone http://github.com/phalcon/cphalcon
cd cphalcon/build
sudo ./install

Note that running the installation script will replace any version of Phalcon installed before.

PackageCloud.io has been updated to allow your package manager (for Linux machines) to upgrade to the new version seamlessly.

NOTE: Windows DLLs are now available in our Github Release page.
NOTE: PackageCloud (linux distributions) will be updated within an hour of this blog post.

We encourage existing Phalcon 3 users to update to this version.

<3 Phalcon Team

01010000011010000110000101101100011000110110111101101110010100000100100001010000
TLDR; We released new docs, messed up, fixed it, enhancing it now, new translation platform.

Hello everyone!

Last week we have released a new Phalcon version 3.2 as well as our new documentation.

Well, that did not go as planned, since we ended up with a lot of angry developers, because the old documentation was not available (at least temporarily) and also we had a lot of broken links in search engines.

We tried to rectify the issue as fast as possible so we have several redirects that point old links to where they are supposed to. We have also created https://olddocs.phalconphp.com/ which contains all the old documents. That site will remain active for quite a long time, so you don't need to worry if you are behind in upgrating to a later version of Phalcon. :)

Changes

The biggest chance that we have been working on the last few months, was to change all of our documents to the markdown format from reStructured Text. Although this was not a huge task, it was time consuming. We also addressed the issue of broken links, image files left over from old documents etc.

Once that process was completed, we tied up the documentation to Crowdin in order to allow contributors translate our documentation in different languages. As with any new technology, we had some setup issues that were only identified after we released 3.2.

Note that there are indeed some CSS issues with the documentation that we expect to have them resolved by next week.

Docs

The docs repository had to be split into two. One (docs-app) would contain the Phalcon application that handles the documentation, contains the stylesheets etc. while the second one (docs) the one that contains all the markdown documents with the contents of our documentation.

The Crowdin team was simply amazing during this process. Not only have they fixed stuff we broke in our integration, but they also guided us on how to create an easy to maintain workflow so that we can easily release our new documentation, translated, whenever we release a new version.

You can find our docs-app repository here and the docs repository here.

For each release we will have a branch in the docs repository that will contain the documentation for that specific release with the added functionality.

The beauty of using Crowdin is that it identifies identical strings of text throughout branches. As a result if contributors say have translated all of the documents in Spanish for 3.2, when we release 3.3 only the changed text will appear as not translated.

We have to thank once again Crowdin for their tremendous help with our implementation and for hosting our translations/documents in their platform. We highly recommend their service:

Crowdin Logo

Phalcon Documentation: https://crowdin.com/project/phalcon-documentation

Website

We have also ported all of the translations from Transifex to Crowdin so that we can use only one platform for our translations. The Crowdin project is located here. We made an announcement in Transifex for all translators there, and hopefully we will see everyone migrate to the new platform.

As always any suggestions for new languages or even corrections in our text are more than welcome!

Thank you!

Thank you all for your contributions! You guys rock!

<3 Phalcon Team

References:

01010000011010000110000101101100011000110110111101101110010100000100100001010000

With Phalcon 3.2.0 there were many new features and bugs fixed. Today we will write about most important things you need to know and show some code examples of new features.

Added Factory Adapter loaders #11001

With this feature you can load your services in more simplified way using for example ini file:

[database]
host = TEST_DB_MYSQL_HOST
username = TEST_DB_MYSQL_USER
password = TEST_DB_MYSQL_PASSWD
dbname = TEST_DB_MYSQL_NAME
port = TEST_DB_MYSQL_PORT
charset = TEST_DB_MYSQL_CHARSET
adapter = mysql
<?php

use Phalcon\Config\Adapter\Ini;
use Phalcon\Di;
use Phalcon\Db\Adapter\Pdo\Factory;

$di = new Di();
$config = new Ini('config.ini');

$di->set('config', $config);

$di->set(
    'db', 
    function () {
        return Factory::load($this->config->database);
    }
);

This will properly create your database instance and you can change database adapter to another one if necessary in the ini file anytime without changing your code.

Added ability to sanitize URL to Phalcon\Filter

There were added new sanitize filter - url which allows you to clear your urls. For example:

<?php

use Phalcon\Filter;

$filter     = new Filter();
$wrongUrl   = 'http://juhara��.co�m';
$correctUrl = $filter->sanitize($wrongUrl, 'url');

echo $correctUrl; // displays 'http://juhara.com'

Added Phalcon\Mvc\Model::hasUpdated and Phalcon\Mvc\Model:getUpdatedFields, way to check if fields were updated after create/save/update, Added option to disable snapshot update on create/save using Phalcon\Mvc\Model::setup(['updateSnapshotOnSave' => false]) or phalcon.orm.update_snapshot_on_save = 0 in php.ini

In Phalcon 3.1.0 we changed the behavior of snapshots; they are now updated on model creation/update. This could potentially cause problems to your application if you execute Model::getChangedFields in afterUpdate(), afterSave() or afterCreate(). This change was done to fix other things also (for example dynamic update).

Right now you have two options:

  • change your methods from hasChanged(), getChangedFields(), getSnapshotData() to hasUpdated(), getUpdatedFields(), getOldSnapshotData() or
  • add phalcon.orm.update_snapshot_on_save = 0 to your php.ini to disable snapshot updating on save.
<?php

use Phalcon\Mvc\Model;

class User extends Model
{
  public function initialize()
  {
      $this->keepSnapshots(true);
  }
}

$user       = new User();
$user->name = 'Test User';
$user->create();
var_dump($user->getChangedFields());
$user->login = 'testuser';
var_dump($user->getChangedFields());
$user->update();
var_dump($user->getChangedFields());

On Phalcon 3.0.0 output was:

array(1) {
[0]=>
string(4) "name"
}
array(2) {
[0]=>
string(4) "name"
[1]=>
string(5) "login"
}
array(2) {
[0]=>
string(4) "name"
[1]=>
string(5) "login"
}

On Phalcon 3.1.0 and later it is:

array(0) {
}
array(1) {
[0]=>
string(5) "login"
}
array(0) {
}

Model::getUpdatedFields will properly return updated fields or as mentioned above you can go back to the previous behavior by setting the relevant ini value.

Added support for having option in Phalcon\Paginator\Adapter\QueryBuilder #12111

From now on you can use Phalcon\Mvc\Model\Query\Builder::having and Phalcon\Paginator\Adapter\QueryBuilder.

Let's assume you have such a table stock:

DROP TABLE IF EXISTS `stock`;
CREATE TABLE `stock` (
`id`    INT(11)     NOT NULL,
`name`  VARCHAR(32) NOT NULL,
`stock` INT(11)     NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

LOCK TABLES `stock` WRITE;
INSERT INTO `stock` (`id`, `name`, `stock`) VALUES
(1, 'Apple', 2),
(2, 'Carrot', 6)
(3, 'pear', 0);
UNLOCK TABLES;

ALTER TABLE `stock`
ADD PRIMARY KEY (`id`);

ALTER TABLE `stock`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;

And this code:

<?php

use Phalcon\Di\FactoryDefault;
use Phalcon\Paginator\Adapter\QueryBuilder;

class Stock extends Phalcon\Mvc\Model {};

$di            = new FactoryDefault();
$modelsManager = $di->get('modelsManager');
$builder       = $modelsManager
                    ->createBuilder()
                    ->columns('*, COUNT(*) as stock_count')
                    ->from(['Stock' => Stock::class])
                    ->groupBy('name')
                    ->having('SUM(Stock.stock) > 0');

$paginate = (
    new QueryBuilder(
        [
            'builder' => $builder,
            'limit'   => 1,
            'page'    => 2
        ]
    )
)->getPaginate();
var_dump($paginate->total_pages); // now it will return 2, previously it was 3
var_dump($paginate->total_items); // now it will return 2, previously it was 3

Please note:

  • MySQL(and other databases) will need to select all rows and do a count on it.
  • We use groupBy to select columns for those rows.
  • If you don't have groupBy then you need to pass columns option to Phalcon\Paginator\Adapter\QueryBuilder:
<?php

use Phalcon\Di\FactoryDefault;
use Phalcon\Paginator\Adapter\QueryBuilder;

class Stock extends Phalcon\Mvc\Model {};

$di            = new FactoryDefault();
$modelsManager = $di->get('modelsManager');
$builder       = $modelsManager
                    ->createBuilder()
                    ->columns('*, COUNT(*) as stock_count')
                    ->from(['Stock' => Stock::class])
                    ->having('SUM(Stock.stock) > 0');

$paginate = (
    new QueryBuilder(
        [
            'builder' => $builder,
            'limit'   => 1,
            'page'    => 2,
            'columns' => 'id,stock' // this is required in this case
        ]
    )
)->getPaginate();
var_dump($paginate->total_pages); // now it will return 2, previously it was 3
var_dump($paginate->total_items); // now it will return 2, previously it was 3

Added Phalcon\Config::path to get a value using a dot separated path #12221

<?php

use Phalcon\Config;

$config = new Config(
    [
        'test' => [
            'parent' => [
                'property'  => 1,
                'property2' => 'yeah',
            ],
        ],  
    ]
);

echo $config->path('test.parent.property'); // displays 1

Added service provider interface to configure services by context #12783

From now you can move all your $di->set() to classes like this:

<?php

use Phalcon\Di\ServiceProviderInterface;
use Phalcon\DiInterface;
use Phalcon\Di;
use Phalcon\Config\Adapter\Ini;

class SomeServiceProvider implements ServiceProviderInterface
{
    public function register(DiInterface $di)
    {
        $di->set(
            'config', 
            function () {
                return new Ini('config.ini');
            }
        );
    }
}

$di = new Di();
$di->register(new SomeServiceProvider());
var_dump($di->get('config')); // will return properly our config

Added the ability to load services from yaml (Phalcon\Di::loadFromYaml) and php array (Phalcon\Di::loadFromPhp) files, so we can keep the references cleanly separated from code #12784

This feature will let you set your services in yaml files or just in plain php. For example you can load yaml file like this:

config:
  className: \Phalcon\Config
  shared: true
<?php

use Phalcon\Di;

$di = new Di();
$di->loadFromYaml('services.yml');
$di->get('config'); // will properly return config service

Added Phalcon\Cache\Backend\Apcu to introduce pure support of APCu #12098, #11934, Added Phalcon\Annotations\Adapter\Apcu to introduce pure support of APCu #12098

In PHP 7 to use phalcon apc based adapter classes you needed to install apcu and apcu_bc package from pecl. Now in Phalcon 3.2.0 you can switch your *\Apc classes to *\Apcu and remove apcu_bc. Keep in mind that in Phalcon 4 we will most likely remove all *\Apc classes.

Added Phalcon\Mvc\Model\Manager::setModelPrefix and Phalcon\Mvc\Model\Manager::getModelPrefix to introduce tables prefixes #10328

If you want all your tables to have certain prefix and without setting source in all models you can use Phalcon\Mvc\Model\Manager::setModelPrefix:

<?php

use Phalcon\Mvc\Model\Manager;
use Phalcon\Mvc\Model;

class Robots extends Model
{

}

$manager = new Manager();
$manager->setModelPrefix('wp_');
$robots = new Robots(null, null, $manager);
echo $robots->getSource(); // will return wp_robots

Added way to disable setters in Phalcon\Mvc\Model::assign by using Phalcon\Mvc\Model::setup or ini option

Phalcon\Mvc\Model::assign(which is used also when creating/updating/saving model) is always using setters if they exist when have data argument passed, even when it's not needed or not necessary. It can add not needed overhead to your application. From now you can change this behavior by adding phalcon.orm.disable_assign_setters = 1 to your ini file, it will just simply use this->property = value from now on. From Phalcon 4 we will set it to be default behavior.

Added dispatcher::beforeForward event to allow forwarding request to the separated module #121, #12417

With new event you can change module where to forward in easy and clean way:

<?php

use Phalcon\Di;
use Phalcon\Events\Manager;
use Phalcon\Mvc\Dispatcher;
use Phalcon\Events\Event;

$di = new Di();

$modules = [
  'backend' => [
      'className' => 'App\Backend\Bootstrap',
      'path'      => '/app/Modules/Backend/Bootstrap.php',
      'metadata'  => [
          'controllersNamespace' => 'App\Backend\Controllers',
      ],
  ],
];

$manager = new Manager();

$manager->attach(
  'dispatch:beforeForward',
  function (Event $event, Dispatcher $dispatcher, array $forward) use ($modules) {
      $metadata = $modules[$forward['module']]['metadata'];
      $dispatcher->setModuleName($forward['module']);
      $dispatcher->setNamespaceName($metadata['controllersNamespace']);
  }
);

$dispatcher = new Dispatcher();
$dispatcher->setDI($di);
$dispatcher->setEventsManager($manager);
$di->set('dispatcher', $dispatcher);
$dispatcher->forward(
  [
      'module'     => 'backend',
      'controller' => 'posts',
      'action'     => 'index',
  ]
);

echo $dispatcher->getModuleName(); // will display properly 'backend'
Credit to Wojciech Ślawski for the article
01010000011010000110000101101100011000110110111101101110010100000100100001010000

Hello everyone and Happy Father's day!

For our Father's day present, we are extremely happy to announce the release of our newest Phalcon version: 3.2.0.

Our Github issues page has well over 600 issues. However those are mostly New Feature Requests (NFRs), so we started clearing up more and more bugs as well as introducing suggested NFRs. Of course all this would not be feasible without the help of our amazing community: Thank you!

Documentation

Also as part of our goals for Q2, we are releasing our new documentation. We have been working hard to convert all the rst files (reStructuredText) to md (Markdown) and also have a first pass on identifying inconsistencies and enhancing the documentation. Of course a lot more is needed on that, but it will come in future versions.

We are now using Crowdin to help contributors translate our documents. The docs website has been updated but still needs a little bit of love with the stylesheet (coming very soon). Also you will note that the site mentions version 3.1; we will fix that this week coming to ensure that every document is properly versioned in Crowdin.

Our new documentation needs admittedly a little bit of fine tuning in terms of the CSS and the menus. This will be done in the upcoming week. Also, we are going through all the documents and ensuring the content is correct and accurate throughout. Examples and new functionality of new releases will also be added from now on, before we release so that the documents are up to date always.

NOTE: The documentation for previous versions is located here: https://olddocs.phalconphp.com.

Release

The release tag can be found here: 3.2.0. The Windows DLLs are in the releases Github page.

Changelog

  • Phalcon will now trigger E_DEPREACATED by using Phalcon\Mvc\Model\Criteria::addWhere, Phalcon\Debug::getMajorVersion, Phalcon\Dispatcher::setModelBinding, Phalcon\Tag::resetInput, Phalcon\Mvc\Model\Validator::__construct
  • Added Factory Adapter loaders #11001
  • Added ability to sanitize URL to Phalcon\Filter
  • Added missed $type argument to interface Phalcon\Mvc\Model\Query\BuilderInterface::join() to specify type join
  • Added Phalcon\Mvc\Model::hasUpdated and Phalcon\Mvc\Model:getUpdatedFields, way to check if fields were updated after create/save/update
  • Added support for having option in Phalcon\Paginator\Adapter\QueryBuilder #12111
  • Added Phalcon\Config::path to get a value using a dot separated path #12221
  • Added service provider interface to configure services by context #12783
  • Added the ability to load services from yaml (Phalcon\Di::loadFromYaml) and php array (Phalcon\Di::loadFromPhp) files, so we can keep the references cleanly separated from code #12784
  • Added Phalcon\Cache\Backend\Apcu to introduce pure support of APCu #12098, #11934
  • Added Phalcon\Annotations\Adapter\Apcu to introduce pure support of APCu #12098
  • Added option to disable snapshot update on create/save using Phalcon\Mvc\Model::setup(['updateSnapshotOnSave' => false]) or phalcon.orm.update_snapshot_on_save = 0 in php.ini
  • Added Phalcon\Mvc\Model\Manager::setModelPrefix and Phalcon\Mvc\Model\Manager::getModelPrefix to introduce tables prefixes #10328
  • Added methods Phalcon\Mvc\Model\Query\Builder::andHaving, Phalcon\Mvc\Model\Query\Builder::orHaving, Phalcon\Mvc\Model\Query\Builder::betweenHaving, Phalcon\Mvc\Model\Query\Builder::notBetweenHaving, Phalcon\Mvc\Model\Query\Builder::inHaving, Phalcon\Mvc\Model\Query\Builder::notInHaving
  • Added parameters skip_on_insert, skip_on_update and allow_empty_string and fixed a bug for renamed integer columns in Phalcon\Mvc\Model\MetaData\Strategy\Annotations::getMetaData
  • Added way to disable setters in Phalcon\Mvc\Model::assign by using Phalcon\Mvc\Model::setup or ini option
  • Added ability to sanitize special characters to Phalcon\Filter
  • Added a new Phalcon\Mvc\Model\Binder::findBoundModel method. Params fetched from cache are being added to internalCache class property in Phalcon\Mvc\Model\Binder::getParamsFromCache
  • Added Phalcon\Mvc\Model\Criteria::createBuilder to create a query builder from criteria
  • Added dispatcher::beforeForward event to allow forwarding request to the separated module #121, #12417
  • Added Phalcon\Security\Random:base62 to provide the largest value that can safely be used in URLs without needing to take extra characters into consideration #12105
  • Added Phalcon\Assets\ResourceInterface. So now Phalcon\Assets\Inline and Phalcon\Assets\Resource implements ResourceInterface
  • Added Phalcon\Assets\Collection::has to checks whether the resource is added to the collection or not
  • Added Phalcon\Cli\Dispatcher::getOption, Phalcon\Cli\Dispatcher::hasOption and the options as parameter to cli handlers
  • Added Phalcon\Config\Adapter\Grouped to allow usage of multiple configuration files/adapters in a simple format #12884
  • Added DISTINCT type for Phalcon\Text::random
  • Added autopadding feature for Phalcon\Crypt::encryptBase64 and Phalcon\Crypt::decryptBase64 #12490
  • Fixed Dispatcher forwarding when handling exception #11819, #12154
  • Fixed params view scope for PHP 7 #12648
  • Fixed Phalcon\Mvc\Micro::handle to prevent attemps to send response twice #12668
  • Fixed Di::set, Di::setShared to allow pass more than 10 arguments #12299
  • Fixed Phalcon\Mvc\Model\MetaData\Strategy\Annotations::getColumnMaps where only renamed columns where returned if there was one
  • Fixed Phalcon\Mvc\Micro:handle to correctly handle before handlers #10931
  • Fixed Phalcon\Mvc\Micro:handle to correctly handle afterBinding handlers
  • Fixed Phalcon\Mvc\Model::hasChanged to correctly use it with arrays #12669
  • Fixed Phalcon\Mvc\Model\Resultset::delete to return result depending on success #11133
  • Fixed Phalcon\Session\Adapter::destroy to correctly clear the $_SESSION superglobal #12326, #12835
  • Fixed Phalcon\Assets\Collection:add to avoid duplication of resources #10938, #2008
  • Fixed Phalcon\Mvc\View\Engine\Volt::compile to not throw exception in case of absence the file and stat option is true #12849
  • Fixed Phalcon\Mvc\Collection::getReservedAttributes to workaround for PHP 7/7.1 bug with static null when extending class phalcon/incubator#762, phalcon/incubator#760
  • Fixed Phalcon\Cache\Backend\Redis::__construct and Phalcon\Cache\Backend\Redis::_connect to correctly handle the Redis auth option #12736
  • Fixed Phalcon\Mvc\Collection::getReservedAttributes, added missing properties to reserved attributes phalcon/incubator#762, phalcon/incubator#760
  • Fixed Phalcon\Mvc\Router\Annotation::processActionAnnotation to support PATCH request

Update/Upgrade

Phalcon 3.2.0 can be installed from the master branch, if you don't have Zephir installed follow these instructions:

git clone http://github.com/phalcon/cphalcon
cd cphalcon/build
sudo ./install

Note that running the installation script will replace any version of Phalcon installed before.

PackageCloud.io has been updated to allow your package manager (for Linux machines) to upgrade to the new version seamlessly.

NOTE: Windows DLLs are now available in our Github Release page.
PackageCloud will be updated shortly.

We encourage existing Phalcon 3 users to update to this version.

<3 Phalcon Team

01010000011010000110000101101100011000110110111101101110010100000100100001010000

We have received the following testimony from Michael Hanekom in our team email. Michael agreed to share his experience in our blog, and we are doing so without any edits:

Greetings to the Phalcon Team!

I am a 20 year veteran of corporate software development and I have followed Phalcon PHP with much excitement from it's early days till now.

Over the past 2 years we have created https://r8em.co.za as your platform to rate anything. Initially targeting local businesses and growing it into an international offering down the line.

The platform is a hybrid of technologies but uses a multi-module Phalcon setup running on Nginx servers scaling on AWS Elastic Beanstalk. We are also using Phalcon's database and caching abilities including a myriad of other features to deliver content to our expected 100,000+ concurrent users. Our current dataset includes roughly 30 million records on MariaDB and we serve high-speed sub-second searches using ElasticSearch. I am really happy that I made the move to Phalcon years ago and would recommend it to anyone considering themselves an expert in "best of breed" technologies.

Thank you Phalcon Team for all your hard work! You have made my life so much easier when it comes to deciding on a high-performance, feature-rich web development framework.

Looking forward to many more years and greater adoption of Phalcon PHP by some of the big players.

Best regards

Michael Hanekom Chief Technology Officer r8em - your platform to rate anything

Thank you Michael for your kind words! It is really rewarding to read that our work has helped Michael and his company perform their tasks better and faster.

We welcome any other testimonials so that we can spread the word about Phalcon and how it can help your projects/company.

<3 Phalcon Team

01010000011010000110000101101100011000110110111101101110010100000100100001010000

This is a guest post from Scott Anderson at Nanobox.

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:

run.config:
  engine: php  
  engine.config:    
    runtime: php-7.1    
    document_root: public    
    extensions:
      - phalcon  
  extra_steps:
    - echo "alias phalcon=\'phalcon.php\'" >> /data/var/home/gonano/.bashrc

This tells Nanobox to:

  • Use the PHP engine, a set of scripts that build your app's runtime.
  • Use PHP 7.1.
  • Set the Apache document root to public.
  • Include the Phalcon extension. Nanobox takes a bare-bones approach to extensions, so you'll likely need to include other extensions. More information can be found here.
  • Add a bash alias for Phalcon Devtools so you can just use the phalcon command.

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.

# start nanobox and drop into a nanobox console
nanobox run

# cd into the /tmp directory
cd /tmp

# generate a new phalcon app
phalcon project myapp

# change back to the /app dir
cd -

# copy the generated app into your project
cp -a /tmp/myapp/* .

# exit the console
exit

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 phalcon.dev

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 phalcon.dev.

Check Out the Environment

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

# drop into a Nanobox console
nanobox run

# check the php version
php -v

# check that phalcon devtools are available
phalcon info

# check that your local codebase is mounted
ls

# exit the console
exit

Phalcon & 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.

Resources

Nanobox

Phalcon

01010000011010000110000101101100011000110110111101101110010100000100100001010000

Hello everyone!

Back in March, we asked our community to fill in a short survey, in order to gauge why people are using Phalcon, what we should be doing better etc.

The survey was very brief and consisted of the following questions:

  • Why did you choose to use Phalcon (main reason but also expand please)? *
  • Do you use Phalcon in production? (elaborate) *
  • Comments for the team (optional)
  • Github username (optional)

We received 103 replies and we thank you all of you that took the time to give us input.

Results

Why did you choose to use Phalcon

  • 90.29% (93/103) responses chose Performance which is one of the main attributes of Phalcon.
  • 61.17% (63/103) also chose Flexibility/Simplicity
  • 3.88% (4/103) chose the Community
  • 2.91% (3/103) stated that they liked it
Clearly the above percentages do not add to 100% because many users chose more than one attribute of Phalcon as the reason they chose it

Do you use Phalcon in production?

79.61% (82/103) replied Yes. There were also a frew "planning to in the future" and of course some "no".

The above was a welcomed surprise. Survey takers in some cases informed us of their websites, which was awesome to see.

This data makes us redouble our efforts to ensure that our users have a high quality and fast framework that can help them and their applications.

Thank you all!

Comments for the team (optional)

The comments ranged from praise to some complains about the documentation (we are working on it).

A sample is below:

Keep up the good work.
It's my favorite framework
With Phalcon comes great responsibility :)
View's file structure needs a bit more documentation. I had to look up on stackoverflow to get the gist of it's file structure.
Excellent work guys, I love you team
Add full features look like laravel, big project orm important and needed
Keep up the improvement of docs and tutorials
Better documentation
Follow Uncle Bob's clean code rules .. your class and methods are to damn long! Aside from that though, God bless you and thank you so much for the work you do! :)
They did a great job and I would love to complete what I am learning now and start contributing
Phalcon team is awesome. But i think, developments should be more frequent.
Please, improve documentation...
Great work guys! Everything works like a charm, with Postgres or MySQL, with Nginx or Apache, and the documentation is awesome!
Maybe you need a bigger team, more communication, less open bugs, shared hostings support, easier way to debug for beginners like me ...
Currently I am using BoltCMS for a new project (mostly because the backend and documentation is easy for me to use/understand) but I would really love to use a similar project if it was done using Phalcon. Another thing missing is a solid e-commerce platform based on Phalcon (I would gladly pay to use/support something like that)
In my mind you should concentrate on examples where are used good practices, maybe CQRS or other architecture solution. Important thing is multimodule architecutre. In my mind its way to make Phalcon more popular for serious projects. Currently are some issues in this architecture, for example dispatching and security check. Make it php 7.1 compatible :)
Maybe a more Laravel kind of documentation.
Documentation needs some work. A lot of the powerful features of phalcon are not well documented (eg the validation class). Some more extensive examples would be nice too...
I really miss a proper tutorial..and there are like 5 ways to bootstrap your application and all look amateurish and messy
Great work! Please continue to expand PHQL, its great but can be quite limiting in its capabilities sometimes.
Hopefully there's gonna be updated video tutorials.
Very nice job and a big thank you for your work!

Conclusion

We intend on having these user surveys in regular intervals (say every six months or so) in order to get feedback from our community.

Clearly from this survey two things stand out:

  1. Speed/Performance is very important
  2. The documentation needs a lot of work

We will ensure that speed/performance are number one in our priority list, while keeping the framework feature rich. Indeed our documentation has not been stellar and more importantly not uniformed. Work on this has already started in Q1 where a total revamp of the documentation is scheduled at the end of this quarter (Q2) or earlier if possible.

We are also working on our Q2 goals (new blog post coming shortly) which take the above in consideration.

Appendix

Raw data file

01010000011010000110000101101100011000110110111101101110010100000100100001010000

Continuing from our yesterday's post, we are checking the benchmarks for micro PHP frameworks.

From feedback from the community, we intend to expand this test to be a bit more realistic, offering CRUD tests, JSON responses etc. We will work on this with the community in our repo so any help and suggestions are more than welcome!

Phalcon offers the Phalcon\Mvc\Micro application, used to create micro applications. Again we hope that this blog post will give an indication on what one can expect from a Phalcon Micro application. Note that this blog and our website both run using the Phalcon Micro application. Both sites run on an Amazon VM with 512Mb RAM and 1 vCPU.

Methodology

We used the same methodology as when benchmarking the full frameworks. A simple Hello World was displayed on the screen. Naturally, this is not a real life example, but it demonstrates the minimum resources needed to display a simple string on the screen.

As with the previous test, we are measuring the the time it takes for each framework to start, run each action, present the result needed and free up the resources at the end of the request. Any PHP application based on the said framework will need this time and resources. It is safe to assume that any implementations that will be much more complex than this one will require additional resources per request.

The ab benchmarking tool from Apache was used for these tests. 1,000 requests using 5 concurrent connections for each framework.

Results

We will start with the results of our benchmark. The hardware used, raw data as well as setup/configuration changes we did for each framework are further down in this post.

Included Files

We have used the get_included_files() function to figure out how many files have been included for one request. The call to the function was at the end of the entry point, usually index.php (lower is better). As one can expect, most micro frameworks can be dispatched in one file.

image

Memory used (KB)

We have used the memory_get_usage() function to figure out how many much memory was used for each request. The call to this function was at the end of the entry point, usually index.php. (lower is better).

image

Requests per Second (mean)

Using the ab tool, we measured the requests per second that each framework could handle. (higher is better).

image

Time to complete 1,000 requests

Again using the ab tool, we measured the time it took to complete 1,000 requests. (lower is better).

image

Conclusion

Just as our previous benchmark, Phalcon is outperforming any other framework in this test.

A couple of observations:

  • We modified Lumen and Silex moving services, routes etc. to the index.php file so that we can have a more realistic idea of how many files would be included for a simple request.
  • In the Requests per Second test, the requests are much closer between Phalcon, Limonade and FatFree. Still 100-300 requests per second slower, but this shows how these frameworks perform in the micro application world.
  • The Time to complete test is also close between Phalcon, Limonade and FatFree, between 0.1-0.2 seconds.

Again we will stress out that these are bare bones applications on Micro frameworks, intended to give you an idea of how fast your framework is, in a simple test. The results will definitely vary based on your installation and implementation. Adding more services as needed by the functionality of each application developed will significantly increase the values shown above (or decrease in the Requests per second test).

As mentioned in our previous post nothing beats a good design or better yet, the best design for the application needs. Phalcon offers a fast full stack framework as well as a micro one. The main difference (here comes the sales pitch ) is that since Phalcon is memory resident and loosely coupled, it offers a wealth of components ready to be used whenever needed, without having to slim down the framework itself i.e. speed vs. features. It is worth a look.

NOTE: If any of our readers have suggestions that we could implement to make this benchmark as realistic as possible, feel free to issue a pull request with your suggestions or your submission of another framework
The last benchmark that one can find is from TechEmpower which was conducted on November 16, 2016. According to their test schedule, we should have seen round 14 in February this year but that has not happened yet.

<3 Phalcon Team

Appendix

Github Repo

Framework Benchmarks

Hardware

I set up a virtual machine with Ubuntu Server 16.10. We stopped the X server and allocated 4GB of RAM and 50GB of hard drive space.

After the system was updated to the latest packages, Apache was installed on the virtual machine. For PHP and Phalcon we chose to use PHP 7.1 using the PPA from Ondřej Surý.

PHP

Version
PHP 7.1.3-3+deb.sury.org~yakkety+1 (cli) (built: Mar 25 2017 14:01:32) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
    with Zend OPcache v7.1.3-3+deb.sury.org~yakkety+1, Copyright (c) 1999-2017, by Zend Technologies
Modules

OPCache was enabled and the installation was the default one without any modifications in php.ini. The modules installed were:

calendar, Core, ctype, curl, date, dom, exif, fileinfo, filter, ftp, gettext, hash, iconv, intl, json, libxml, mbstring, mcrypt, openssl, pcntl, pcre, PDO, phalcon, Phar, posix, readline, Reflection, session, shmop, SimpleXML, sockets , SPL, standard, sysvmsg, sysvsem, sysvshm, tokenizer, wddx, xml, xmlreader, xmlwriter, xsl, Zend OPcache, zlib

Frameworks

The frameworks compared were:

Limonade has not been updated for nearly 4 years but is a fast micro framework that we thought would be great to include it in our tests

Installation and Changes

We tried to make this test as realistic as possible, ensuring that all frameworks behave in production mode. However, nobody is perfect so any suggestions that the community can provide to tweak each framework to its maximum potential, feel free to issue a pull request in our Github repository.

FatFree

index.php

<?php

$f3=require('lib/base.php');

$f3->route('GET /',
    function() {
        echo 'Hello World!';
    }
);
$f3->run();

Limonade

index.php

<?php

ini_set('display_errors', 0);

require_once __DIR__.'/vendor/lib/limonade.php';

dispatch('/', 'hello');
  function hello()
  {
      return 'Hello World!';
  }
run();

Lumen

public/index.php

<?php

require_once __DIR__.'/../vendor/autoload.php';

try {
    (new Dotenv\Dotenv(__DIR__.'/../'))->load();
} catch (Dotenv\Exception\InvalidPathException $e) {
    //
}

$app = new Laravel\Lumen\Application(
    realpath(__DIR__.'/../')
);

$app->get('/', function () use ($app) {
    return "Hello World!";
//    return $app->version();
});

$app->run();

Phalcon

index.php

<?php

$app = new Phalcon\Mvc\Micro();

$app->get(
    '/',
    function () {
        echo "Hello World!";
    }
);

$app->notFound(
    function() {
        echo "Not Found";
    }
);

$app->handle();

Silex

web/index.php

<?php

use Silex\Application;

ini_set('display_errors', 0);

require_once __DIR__.'/../vendor/autoload.php';

$app = new Application();

$app->get('/', function () use ($app) {
    return "Hello World!";
//    return $app['twig']->render('index.html.twig', array());
})
    ->bind('homepage')
;

$app->error(function (\Exception $e, Request $request, $code) use ($app) {
    return "Error: " . $e->getMessage();
});

$app->run();

ab results

FatFree

This is ApacheBench, Version 2.3 <$Revision: 1706008 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 10.4.6.123 (be patient)

Server Software:        Apache/2.4.18
Server Hostname:        10.4.6.123
Server Port:            80

Document Path:          /micro/fatfree/
Document Length:        12 bytes

Concurrency Level:      5
Time taken for tests:   0.811 seconds
Complete requests:      1000
Failed requests:        0
Total transferred:      420000 bytes
HTML transferred:       12000 bytes
Requests per second:    1233.71 [#/sec] (mean)
Time per request:       4.053 [ms] (mean)
Time per request:       0.811 [ms] (mean, across all concurrent requests)
Transfer rate:          506.01 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.2      0       3
Processing:     1    4   5.4      2      55
Waiting:        1    2   3.0      2      35
Total:          1    4   5.4      2      56

Percentage of the requests served within a certain time (ms)
  50%      2
  66%      3
  75%      3
  80%      3
  90%      9
  95%     15
  98%     26
  99%     28
 100%     56 (longest request)

Limonade

This is ApacheBench, Version 2.3 <$Revision: 1706008 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 10.4.6.123 (be patient)

Server Software:        Apache/2.4.18
Server Hostname:        10.4.6.123
Server Port:            80

Document Path:          /micro/limonade/
Document Length:        12 bytes

Concurrency Level:      5
Time taken for tests:   0.631 seconds
Complete requests:      1000
Failed requests:        0
Total transferred:      404000 bytes
HTML transferred:       12000 bytes
Requests per second:    1584.79 [#/sec] (mean)
Time per request:       3.155 [ms] (mean)
Time per request:       0.631 [ms] (mean, across all concurrent requests)
Transfer rate:          625.25 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.2      0       1
Processing:     1    3   5.3      1      46
Waiting:        0    2   1.4      1      25
Total:          1    3   5.3      2      47

Percentage of the requests served within a certain time (ms)
  50%      2
  66%      2
  75%      2
  80%      3
  90%      4
  95%     14
  98%     24
  99%     30
 100%     47 (longest request)

Lumen

This is ApacheBench, Version 2.3 <$Revision: 1706008 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 10.4.6.123 (be patient)

Server Software:        Apache/2.4.18
Server Hostname:        10.4.6.123
Server Port:            80

Document Path:          /micro/lumen/public/
Document Length:        12 bytes

Concurrency Level:      5
Time taken for tests:   1.328 seconds
Complete requests:      1000
Failed requests:        0
Total transferred:      213000 bytes
HTML transferred:       12000 bytes
Requests per second:    752.89 [#/sec] (mean)
Time per request:       6.641 [ms] (mean)
Time per request:       1.328 [ms] (mean, across all concurrent requests)
Transfer rate:          156.61 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.4      0       2
Processing:     1    6   6.8      3      43
Waiting:        1    5   6.0      3      43
Total:          1    7   6.8      4      44

Percentage of the requests served within a certain time (ms)
  50%      4
  66%      5
  75%      7
  80%     11
  90%     17
  95%     23
  98%     27
  99%     31
 100%     44 (longest request)

Phalcon Micro

This is ApacheBench, Version 2.3 <$Revision: 1706008 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 10.4.6.123 (be patient)

Server Software:        Apache/2.4.18
Server Hostname:        10.4.6.123
Server Port:            80

Document Path:          /micro/phalcon/
Document Length:        12 bytes

Concurrency Level:      5
Time taken for tests:   0.591 seconds
Complete requests:      1000
Failed requests:        0
Total transferred:      179000 bytes
HTML transferred:       12000 bytes
Requests per second:    1691.97 [#/sec] (mean)
Time per request:       2.955 [ms] (mean)
Time per request:       0.591 [ms] (mean, across all concurrent requests)
Transfer rate:          295.76 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.2      0       1
Processing:     0    3   7.0      1      83
Waiting:        0    2   5.1      1      80
Total:          1    3   7.0      2      84

Percentage of the requests served within a certain time (ms)
  50%      2
  66%      2
  75%      2
  80%      2
  90%      3
  95%      9
  98%     25
  99%     31
 100%     84 (longest request)

Silex

This is ApacheBench, Version 2.3 <$Revision: 1706008 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 10.4.6.123 (be patient)

Server Software:        Apache/2.4.18
Server Hostname:        10.4.6.123
Server Port:            80

Document Path:          /micro/silex/web/
Document Length:        12 bytes

Concurrency Level:      5
Time taken for tests:   1.663 seconds
Complete requests:      1000
Failed requests:        0
Total transferred:      251000 bytes
HTML transferred:       12000 bytes
Requests per second:    601.48 [#/sec] (mean)
Time per request:       8.313 [ms] (mean)
Time per request:       1.663 [ms] (mean, across all concurrent requests)
Transfer rate:          147.43 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.5      0       4
Processing:     1    8   9.0      4      57
Waiting:        1    6   7.4      3      48
Total:          1    8   9.0      4      57

Percentage of the requests served within a certain time (ms)
  50%      4
  66%      7
  75%     11
  80%     13
  90%     21
  95%     28
  98%     37
  99%     44
 100%     57 (longest request)
01010000011010000110000101101100011000110110111101101110010100000100100001010000

It has been quite a while since we run our benchmarks against other networks. Actually the last time we had the benchmarks in our documentation was for Phalcon 1.3! Yes we know, we have been neglecting this.

Hopefully this post will offer some perspective on what you can expect from Phalcon and your application. It goes without saying that every application needs the best design for its needs, but using Phalcon can also push your application's performance even further.

Methodology

We have installed the stock application for each framework. We have ensured that there is one route, one controller and one view that will allow us to display Hello World on the screen. Naturally, this is not a real life example, but it demonstrates the minimum resources needed to display a simple string on the screen.

Note: These are the stock applications that each framework offers. The only thing that we changed is to put each framework in Production mode.

This benchmark only measures the time it takes for each framework to start, run each action, present the result needed and free up the resources at the end of the request. Any PHP application based on the said framework will need this time and resources. It is safe to assume that any implementations that will be much more complex than this one will require additional resources per request.

The ab benchmarking tool from Apache was used for these tests. 1,000 requests using 5 concurrent connections for each framework.

Results

We will start with the results of our benchmark. The hardware used, raw data as well as setup/configuration changes we did for each framework are further down in this post.

Included Files

We have used the get_included_files() function to figure out how many files have been included for one request. The call to the function was at the end of the entry point, usually index.php (lower is better).

image

Memory used (KB)

We have used the memory_get_usage() function to figure out how many much memory was used for each request. The call to this function was at the end of the entry point, usually index.php. (lower is better).

image

Requests per Second (mean)

Using the ab tool, we measured the requests per second that each framework could handle. (higher is better).

image

Time to complete 1,000 requests

Again using the ab tool, we measured the time it took to complete 1,000 requests. (lower is better).

image

Conclusion

Phalcon is clearly outperforming any other framework in this test.

Again we will stress out that these are just the stock applications that come with each framework. The results will definitely vary based on your installation. For instance a developer could remove services from a particular framework which will speed it up (at least the included files) but could also add more services which would slow it down.

Nothing beats a good design or better yet, the best design for the application needs. However, if you can gain some performance and lower your memory consumption by just using Phalcon, it is worth a look and a try if you haven't done so already .

NOTE: If any of our readers have suggestions that we could implement to make this benchmark as realistic as possible, feel free to issue a pull request with your suggestions.
The last benchmark that one can find is from TechEmpower which was conducted on November 16, 2016. According to their test schedule, we should have seen round 14 in February this year but that has not happened yet.

<3 Phalcon Team

Appendix

Github Repo

Framework Benchmarks

Hardware

I set up a virtual machine with Ubuntu Server 16.10. We stopped the X server and allocated 4GB of RAM and 50GB of hard drive space.

After the system was updated to the latest packages, Apache was installed on the virtual machine. For PHP and Phalcon we chose to use PHP 7.1 using the PPA from Ondřej Surý.

PHP

Version
PHP 7.1.3-3+deb.sury.org~yakkety+1 (cli) (built: Mar 25 2017 14:01:32) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
    with Zend OPcache v7.1.3-3+deb.sury.org~yakkety+1, Copyright (c) 1999-2017, by Zend Technologies
Modules

OPCache was enabled and the installation was the default one without any modifications in php.ini. The modules installed were:

calendar, Core, ctype, curl, date, dom, exif, fileinfo, filter, ftp, gettext, hash, iconv, intl, json, libxml, mbstring, mcrypt, openssl, pcntl, pcre, PDO, phalcon, Phar, posix, readline, Reflection, session, shmop, SimpleXML, sockets , SPL, standard, sysvmsg, sysvsem, sysvshm, tokenizer, wddx, xml, xmlreader, xmlwriter, xsl, Zend OPcache, zlib

Frameworks

The frameworks compared were:

Installation and Changes

We tried to make this test as realistic as possible, ensuring that all frameworks behave in production mode. However, nobody is perfect so any suggestions that the community can provide to tweak each framework to its maximum potential, feel free to issue a pull request in our Github repository.

FuelPHP

curl https://get.fuelphp.com/oil | sh
oil create fuelphp

fuelphp/fuel/app/bootstrap.php

\Fuel::$env = \Arr::get($_SERVER, 'FUEL_ENV', \Arr::get($_ENV, 'FUEL_ENV', \Fuel::PRODUCTION));
// \Fuel::$env = \Arr::get($_SERVER, 'FUEL_ENV', \Arr::get($_ENV, 'FUEL_ENV', \Fuel::DEVELOPMENT));

fuelphp/fuel/app/views/welcome/index.php

Hello World!

Kohana

wget https://github.com/kohana/kohana/releases/download/v3.3.6/kohana-v3.3.6.zip
unzip kohana-v3.3.6.zip

kohana/application/bootstrap.php

if (isset($_SERVER['KOHANA_ENV']))
{
    Kohana::$environment = constant('Kohana::'.strtoupper($_SERVER['KOHANA_ENV']));
}
Kohana::$environment = Kohana::PRODUCTION;

kohana/application/classes/Controller/Welcome.php

<?php defined('SYSPATH') or die('No direct script access.');

class Controller_Welcome extends Controller_Template {
        public $template = 'welcome';
        public function action_index()
        {
                $this->template->message = 'Hello, World!';
        }

} // End Welcome

kohana/application/views/welcome.php

<?php echo $message; ?>

Laravel

composer create-project --prefer-dist laravel/laravel laravel

laravel/.env

APP_DEBUG=false

laravel/config/app.php

    ...
    'env' => env('APP_ENV', 'production'),
    'debug' => env('APP_DEBUG', false),
    ...

laravel/resources/views/welcome.blade.php

Hello World!

Nette

composer create-project nette/web-project nette
cd nette
chmod -R a+rw temp log

nette/app/presenters/templates/Homepage/default.latte

Hello World!

Phalcon

Downloaded sample from the MVC repository.

phalcon/app/views/index.phtml

Hello World!

Symfony

composer create-project symfony/framework-standard-edition symfony

symfony/app/Resources/views/base.html.twig

Hello World

Yii

composer global require "fxp/composer-asset-plugin:^1.2.0"
composer create-project --prefer-dist yiisoft/yii2-app-basic yii

yii/web/index.php

<?php

// comment out the following two lines when deployed to production
//defined('YII_DEBUG') or define('YII_DEBUG', true);
//defined('YII_ENV') or define('YII_ENV', 'dev');

yii/config/web.php

/**
if (YII_ENV_DEV) {
    // configuration adjustments for 'dev' environment
    $config['bootstrap'][] = 'debug';
    $config['modules']['debug'] = [
        'class' => 'yii\debug\Module',
        // uncomment the following to add your IP if you are not connecting from localhost.
        //'allowedIPs' => ['127.0.0.1', '::1'],
    ];

    $config['bootstrap'][] = 'gii';
    $config['modules']['gii'] = [
        'class' => 'yii\gii\Module',
        // uncomment the following to add your IP if you are not connecting from localhost.
        //'allowedIPs' => ['127.0.0.1', '::1'],
    ];
}
*/
return $config;

yii/views/site/index.php

Hello World!

yii/views/layouts/main.php

<?= $content ?>

Zend Framework

composer create-project zendframework/skeleton-application zf

zf/public/index.php

// Retrieve configuration
$appConfig = require __DIR__ . '/../config/application.config.php';
//if (file_exists(__DIR__ . '/../config/development.config.php')) {
//    $appConfig = ArrayUtils::merge($appConfig, require __DIR__ . '/../config/development.config.php'); 
//}

zf/module/Application/view/layout/layout.phtml

<?= $this->content ?>

ab results

FuelPHP

This is ApacheBench, Version 2.3 <$Revision: 1706008 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 10.4.6.123 (be patient)

Server Software:        Apache/2.4.18
Server Hostname:        10.4.6.123
Server Port:            80

Document Path:          /fuelphp/public/
Document Length:        13 bytes

Concurrency Level:      5
Time taken for tests:   1.827 seconds
Complete requests:      1000
Failed requests:        0
Total transferred:      180000 bytes
HTML transferred:       13000 bytes
Requests per second:    547.28 [#/sec] (mean)
Time per request:       9.136 [ms] (mean)
Time per request:       1.827 [ms] (mean, across all concurrent requests)
Transfer rate:          96.20 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    1   0.6      0       4
Processing:     1    9  10.0      4      72
Waiting:        1    7   8.6      3      61
Total:          2    9  10.0      4      75
WARNING: The median and mean for the initial connection time are not within a normal deviation
        These results are probably not that reliable.

Percentage of the requests served within a certain time (ms)
  50%      4
  66%      8
  75%     12
  80%     15
  90%     23
  95%     31
  98%     40
  99%     45
 100%     75 (longest request)

Kohana

This is ApacheBench, Version 2.3 <$Revision: 1706008 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 10.4.6.123 (be patient)

Server Software:        Apache/2.4.18
Server Hostname:        10.4.6.123
Server Port:            80

Document Path:          /kohana/
Document Length:        13 bytes

Concurrency Level:      5
Time taken for tests:   1.100 seconds
Complete requests:      1000
Failed requests:        0
Total transferred:      180000 bytes
HTML transferred:       13000 bytes
Requests per second:    908.72 [#/sec] (mean)
Time per request:       5.502 [ms] (mean)
Time per request:       1.100 [ms] (mean, across all concurrent requests)
Transfer rate:          159.74 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.5      0       4
Processing:     1    5   5.1      3      45
Waiting:        1    4   4.6      3      45
Total:          1    5   5.0      4      46

Percentage of the requests served within a certain time (ms)
  50%      4
  66%      4
  75%      5
  80%      6
  90%     12
  95%     16
  98%     22
  99%     27
 100%     46 (longest request)

Laravel

This is ApacheBench, Version 2.3 <$Revision: 1706008 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 10.4.6.123 (be patient)

Server Software:        Apache/2.4.18
Server Hostname:        10.4.6.123
Server Port:            80

Document Path:          /laravel/public/
Document Length:        13 bytes

Concurrency Level:      5
Time taken for tests:   4.803 seconds
Complete requests:      1000
Failed requests:        0
Total transferred:      997232 bytes
HTML transferred:       13000 bytes
Requests per second:    208.22 [#/sec] (mean)
Time per request:       24.013 [ms] (mean)
Time per request:       4.803 [ms] (mean, across all concurrent requests)
Transfer rate:          202.77 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.4      0       6
Processing:     4   24  21.0     21     280
Waiting:        4   20  20.2     16     280
Total:          4   24  21.0     21     281

Percentage of the requests served within a certain time (ms)
  50%     21
  66%     29
  75%     33
  80%     36
  90%     43
  95%     54
  98%     71
  99%     99
 100%    281 (longest request)

Nette

This is ApacheBench, Version 2.3 <$Revision: 1706008 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 10.4.6.123 (be patient)

Server Software:        Apache/2.4.18
Server Hostname:        10.4.6.123
Server Port:            80

Document Path:          /nette/www/
Document Length:        13 bytes

Concurrency Level:      5
Time taken for tests:   1.876 seconds
Complete requests:      1000
Failed requests:        0
Total transferred:      264000 bytes
HTML transferred:       13000 bytes
Requests per second:    533.14 [#/sec] (mean)
Time per request:       9.378 [ms] (mean)
Time per request:       1.876 [ms] (mean, across all concurrent requests)
Transfer rate:          137.45 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    1   0.6      0       4
Processing:     1    9   9.0      5      73
Waiting:        1    7   7.7      4      49
Total:          1    9   9.0      5      73
WARNING: The median and mean for the initial connection time are not within a normal deviation
        These results are probably not that reliable.

Percentage of the requests served within a certain time (ms)
  50%      5
  66%      9
  75%     13
  80%     16
  90%     22
  95%     28
  98%     35
  99%     43
 100%     73 (longest request)

Phalcon

This is ApacheBench, Version 2.3 <$Revision: 1706008 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 10.4.6.123 (be patient)

Server Software:        Apache/2.4.18
Server Hostname:        10.4.6.123
Server Port:            80

Document Path:          /phalcon/
Document Length:        13 bytes

Concurrency Level:      5
Time taken for tests:   0.712 seconds
Complete requests:      1000
Failed requests:        0
Total transferred:      180000 bytes
HTML transferred:       13000 bytes
Requests per second:    1403.86 [#/sec] (mean)
Time per request:       3.562 [ms] (mean)
Time per request:       0.712 [ms] (mean, across all concurrent requests)
Transfer rate:          246.77 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.3      0       4
Processing:     1    3   3.9      2      33
Waiting:        0    2   1.7      2      28
Total:          1    4   4.0      3      33

Percentage of the requests served within a certain time (ms)
  50%      3
  66%      3
  75%      3
  80%      3
  90%      6
  95%     11
  98%     19
  99%     24
 100%     33 (longest request)

Symfony

This is ApacheBench, Version 2.3 <$Revision: 1706008 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 10.4.6.123 (be patient)

Server Software:        Apache/2.4.18
Server Hostname:        10.4.6.123
Server Port:            80

Document Path:          /full/symfony/web/
Document Length:        13 bytes

Concurrency Level:      5
Time taken for tests:   4.602 seconds
Complete requests:      1000
Failed requests:        0
Total transferred:      252000 bytes
HTML transferred:       13000 bytes
Requests per second:    217.31 [#/sec] (mean)
Time per request:       23.008 [ms] (mean)
Time per request:       4.602 [ms] (mean, across all concurrent requests)
Transfer rate:          53.48 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.4      0       4
Processing:     4   23  21.3     21     277
Waiting:        3   15  20.2      9     276
Total:          4   23  21.3     22     277

Percentage of the requests served within a certain time (ms)
  50%     22
  66%     27
  75%     30
  80%     32
  90%     38
  95%     46
  98%     55
  99%     72
 100%    277 (longest request)

Yii

This is ApacheBench, Version 2.3 <$Revision: 1706008 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 10.4.6.123 (be patient)

Server Software:        Apache/2.4.18
Server Hostname:        10.4.6.123
Server Port:            80

Document Path:          /yii/web/
Document Length:        12 bytes

Concurrency Level:      5
Time taken for tests:   1.073 seconds
Complete requests:      1000
Failed requests:        0
Total transferred:      179000 bytes
HTML transferred:       12000 bytes
Requests per second:    932.10 [#/sec] (mean)
Time per request:       5.364 [ms] (mean)
Time per request:       1.073 [ms] (mean, across all concurrent requests)
Transfer rate:          162.94 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.4      0       4
Processing:     1    5   7.5      2      54
Waiting:        1    4   6.3      2      42
Total:          1    5   7.5      2      54

Percentage of the requests served within a certain time (ms)
  50%      2
  66%      3
  75%      4
  80%      6
  90%     15
  95%     23
  98%     32
  99%     38
 100%     54 (longest request)

Zend Framework

This is ApacheBench, Version 2.3 <$Revision: 1706008 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 10.4.6.123 (be patient)

Server Software:        Apache/2.4.18
Server Hostname:        10.4.6.123
Server Port:            80

Document Path:          /zf/public/
Document Length:        24 bytes

Concurrency Level:      5
Time taken for tests:   3.731 seconds
Complete requests:      1000
Failed requests:        0
Total transferred:      191000 bytes
HTML transferred:       24000 bytes
Requests per second:    268.05 [#/sec] (mean)
Time per request:       18.654 [ms] (mean)
Time per request:       3.731 [ms] (mean, across all concurrent requests)
Transfer rate:          50.00 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.6      0       4
Processing:     3   18  18.4      8     101
Waiting:        3   13  15.0      5     101
Total:          3   19  18.4      8     101

Percentage of the requests served within a certain time (ms)
  50%      8
  66%     23
  75%     31
  80%     35
  90%     46
  95%     55
  98%     67
  99%     76
 100%    101 (longest request)

Revisions

2017-04-13 18:22 Symfony: changed $kernel = new AppKernel('prod', false); and rerun the results. Kudos (@msvrtan).

01010000011010000110000101101100011000110110111101101110010100000100100001010000

Hey everyone!!

As part of our restructuring and working towards a better more robust framework in terms of features as well as organization, we have removed the IDE stubs from the Phalcon DevTools repository and moved to its own repository.

Since Phalcon is a module that is loaded in memory and always available, there is no way for an IDE such as PHPStorm to interrogate the sources of the framework and offer autocomplete features for namespaces, classes, methods etc.

To work around this issue, the Phalcon team has been generating IDE stubs that can be used with such IDEs.

You can now find those stubs in Packagist:

https://packagist.org/packages/phalcon/ide-stubs

The installation is extremely simple.

Composer

Install Composer in a common location or in your project:

curl -s http://getcomposer.org/installer | php

Create the composer.json file as follows:

{
    "require-dev": {
        "phalcon/ide-stubs": "*"
    }
}

Run the composer installer:

php composer.phar install

Git

Clone the Phalcon IDE Stubs repository in a location of your choosing.

git clone https://github.com/phalcon/ide-stubs.git

Setup your IDE.

For PHPStorm users, you can:

  • Right mouse click on the External Libraries in the Project listing pane
  • Click Configure PHP Include Paths
  • Click the green + button and click Specify Other...
  • Navigate to the folder where the stubs are located
  • Click the Phalcon folder and click OK
  • Click Apply and then OK
Note: The video above shows how to enable the IDE stubs cloning the DevTools. The installation is the same, all you have to do is locate the Phalcon project

<3 Phalcon Team

01010000011010000110000101101100011000110110111101101110010100000100100001010000