Cakephp version 3 have a nice ORM. When using the cakephp/orm, it may be nice to integrate cakephp/migration than any other migration libraries, even though it uses phinx under the hood.
Lets see how we can install and integrate cakephp/migration in our application.
1 composer require cakephp/migrations:dev-master The dev-master is currently passed for we need the latest version of master branch. Before this pull request, it was having dependency on cakephp/cakephp, which is not needed.
Working with cakephp/orm library, I needed to log all the queries. Cakephp provides a way to do it via cakephp/log.
1 2 3 4 5 6 7 8 9 <?php use Cake\Log\Log; Log::config('queries', [ 'className' => 'File', 'path' => '/my/log/path/', 'file' => 'app', 'scopes' => ['queriesLog'] ]); But you are not limited, if you need to configure it to a PSR-3 logger like monolog/monolog
1 2 3 4 5 6 7 8 9 10 <?php use Cake\Log\Log; use Monolog\Logger; use Monolog\Handler\StreamHandler; Log::config('default', function () { $log = new Logger('cli'); $log->pushHandler(new StreamHandler('php://stdout')); return $log; }); That was pretty simple and it logs to cli.
Do you know CakePHP version 3 has a lovely ORM which can be used as standalone?
Thank you José Lorenzo Rodríguez and every contributor, for your hard work.
1 composer require cakephp/orm That’s it.
Working on I noticed I need to do some pagination. Oh, remember we have illuminate/pagination. Why not use it?
Problem, there seems no one have implemented it. How could we achieve it? Lets do it.
1 composer require illuminate/pagination If you are using a psr-7 request / response here is the middleware for you.