PHP serverless abstraction framework…

…as serverless architecture picks up steam in the market I predict we will see more and more languages adopting it; is not whole sale from the vendors then from the community itself. As an example here is Bref, a serverless framework for PHP; it can run on it’s own or be used as a bridge for other existing frameworks. Ala Laravel or Slim or CodeIgnitor as AWS Lambda functions. Not a AWS fan? That’s ok, Bref can deploy to any other cloud provider with minimal effort as well. If nothing else, it is worth a read,

https://github.com/mnapoli/bref

AWS Lambda internals

Ran and Nitzan over at epsagon did a two part article on Medium about  AWS Lambda and its internals / runtime environment. It is a pretty interesting read if you are into the serverless architecture specifically or Lambda in general.

Run your End-to-End tests using headless Chrome; Docker_Puppeteer_Jest Docker Image is announced!

About a year ago myself and @ibotpeaces sat down for a couple hours to to put together a docker images with headless Chrome that we could use for End-to-End (user acceptance) testing. At the time the tooling of both Docker and Jest where not at a place at we could get a POC (proof of concept) functional give the constants of the process being a container service, easy integration into existing projects, and using a well adopted JavaScript testing framework.

Google Chrome
Google Chrome
Docker
Docker

 

 

 

 

 

Fast forward to March 2018 and not only has the containerization tooling but advanced significantly but also the headless Chrome control systems. As such I sat down once gain to look into this tool chain. I am happy to announce `Docker Puppeteer Jest‘ docker image. As the name suggests running the image will spin up a headless Chrome instance, controlled by Puppeteer that triggers Jest test suites. Outputting both terminal response and image captures if so instructed.

Checkout the image on the Docker Hub or the repo on GitHub. Let me know what you think or if you find it useful. I’d love to hear from you.

 

Yii2 2.0.14 released; bringing with it some excellent changes.

  • The Yii2 team has release the latest version of the Yii2 framework. With it comes improvements in the following (but not limited to) areas:
  • Scalability and concurrency
  • Validator enhancements
  • Behaviors
  • Databases and ActiveRecord
    • Custom data types and object conditions
    • Query Builder flexibility
    • Upserts
    • Schema builder and migrations
    • New query caching syntax
    • Active Record relations
  • Security
  • Events
  • APIs, serializers and filters

… and much more. Head over to the release notes to read about it all the changes. It is defiantly worth the update.

RE-post: My personal experience migrating a module rom Yii1.x to Yii2.x

(Originally posted on the Sourcetoad Blog circa 20015)

Yii is an amazing framework. As it has been iterated on version 2 is now out and is quickly picking up adoption. With this comes the need to migrate components, modules, and a whole slew of other logic. This blog is a few pointers that we picked up along the way while doing a forum migration. This was the first feature migration we did in house, it was an interesting experience.

RTFM, this may seem a no brainer but read the manual, specifically about the Yii1->2 changes. http://www.yiiframework.com/doc-2.0/guide-intro-upgrade-from-v1.html
Use a source control system. GiT, SVN, Mercurial, etc.
Run the tests, make change, run tests, refactor, run tests, commit, run tests
Pick a specific part of logic / cord to replace. GridViews, DetailList, etc. Do one chunk at a time.
Give back to the community, no one like that guy that takes and takes and never gives back.

One of the most obvious changes has been the inclusion of autoloading classes. Good bye require_once(‘composer/autoloader.php’), hello namespacing. With this change the class names have become much more sane. No more ‘CBaseModel’, now \BaseModel.

The model level logic has seen a substantial change as well. “…In 1.1, query building was scattered among several classes, including CDbCommand, CDbCriteria, and CDbCommandBuilder. Yii 2.0 represents a DB query in terms of a Query object that can be turned into a SQL statement with the help of QueryBuilder behind the scene…” (Yii2 documentation). Now queries are similar this example:

$modelData = \packageName\common\models\ModelName::find()->andWhere([‘id’ => $userId])->one();

Idealy this would return the user’s data from the specified model.

Moving on the view level widgets have had a measurable change as well:
Old:

$this->widget('yii.widgets.grid.CGridView', array(
    'dataProvider'->$dataProvider,
    'columns'=> array(
        'title',         // display the 'title' attribute
        'category.name', // display the 'name' attribute of the 'category' relation
        'content:html',  // display the 'content' attribute as purified HTML
        array(           // display 'create_time' using an expression
            'name'=>'create_time',
            'value'=>'date("M j, Y", $data->create_time)',
        ),
        array(// display 'author.username' using an expression
            'name'=>'authorName',
            'value'=>'$data->author->username',
        ),
        array(// display a column with "view", "update" and "delete" buttons
            'class'=>'CButtonColumn',
        ),
    ),
));

New:

GridView::widget([
    'dataProvider' => $dataProvider,
    'columns'       => [
        [
            'class' => 'yii\grid\SerialColumn'
        ],
        'title',        // display the 'title' attribute
        'category.name',// display the 'name' attribute of the 'category' relation
        'content:raw',  // display the 'content' attribute as purified HTML
        [               // display 'create_time' using an expression
            'name' => 'create_time',
            'value' => 'date("M j, Y", $data->create_time)',
        ],
    ],
    [// display 'author.username' using an expression
        'name' => 'authorName',
        'value' => '$data->author->username',
    ],
    [
        'class' => 'yii\grid\ActionColumn'], //CRUD UI elements
    ]
]);

The astute eye will notice that the base code has simply been updated to the current recommendations. the main change being how the widget is instantiated. The astute will also notice the new column’s `SerialColumn` and `ActionColumn`. These two handy classes provide serialized numbering and CRUD UI elements for the column data. DetailView, ItemView, etc have all been iterated on in this way.

That is all the time we have for today but we hope this has provided insightful. It is highly recommended you take a look at the documentation provided by the Yii team for even more details. http://www.yiiframework.com/doc-2.0/guide-intro-upgrade-from-v1.html