DANIEL WERNER

Senior Software Developer | TDD and Clean Code enthusiast | Open-source contributor and maintainer

Under the hood: How model attributes work in Laravel

Laravel model attributes are basically representing the database fields for the given model. When data is retrieved from the database, it can be accessed through the model as they were actual properties of the model instance: $model->database_column_name. However the attributes are not real properties of the instance, but they are stored in the protected $attributes property. The attributes are accessed using the __get magic method. This makes it possible to do some cool things with them like mutations and casting. As this in an under the hood post, I won’t explain what you can do with attributes, you can find...


Using Github actions and Deployer for creating CI/CD for Laravel

In one of my previous articles I’ve written about how to create an automated pipeline for continuous integration and continuous delivery using travis. Lately GitHub actions are quite popular, I am also experimenting with them. I started by reading the articles written by the guys from Spatie, you can find them here and here. While setting up the actions I encountered some issues with the mysql service, I’ll dive into it later. Let’s set up the same pipeline as last time. Run the tests for every push and deploy the application if the tests are successful. TL;DR; For those who...


Automated linux server backup with Dropbox

Introduction I was looking around for some low cost backup solution for my server when I got an idea. Let’s use dropbox for that. The free version of dropbox has 2 GB of space and it has an official linux client. The offered space is not too much, but for smaller sites it is good enough. I’ve created a collection of scripts for the backup, it creates the backup of the given input directory, from the Nginx configurations and all databases. The backup is stored in the synchronized Dropbox directory the last 30 files are kept, the older ones are...


A recap of 2019

This year is about to end, so I thought it might be interesting to write a recap of what I did this year. This is the first time I am writing this kind of blog post, hopefully there will be more of them in the future. Open source development I created my first open source project back in 2009, but after that, for a really long time I only used OSS in my projects, without giving back to the community. This year I’ve continued with the OSS development. I created two php packages: Laravel SchemaCrawler and PHP Quality Tools. Developing...


Set up CI/CD for your Laravel app with GitHub, Travis, and Deployer

The Laravel ecosystem has great tools for managing automatic deployments: Envoyer, Forge and for serverless deployments there is Vapor. These are easy to use and affordable solutions for automatic deployment of Laravel applications. But if you are developing open source applications, or just looking for a free solution, you can set up Travis CI for continuous integration and continuous deployment. It is free for public GitHub projects. In this article I am going walk you through all the necessary steps from configuring the server through deployer configuration all the way to setting up Travis. Server configuration I assume you already...


PHP Quality Tools package

Introduction If we’d like to write error free, robust, high quality PHP code, the static code analyzers can be of great help. If you work on open-source projects you can take the advantage of using Scrutinizer and StyleCI for these purposes. However if you are working on other, proprietary projects, you might need to run/configure these tools yourself. There are plenty of such tools to use with php, you can find quite comprehensive lists on other websites, for example here and here. My tools of choice are the following: PHP Code Sniffer – check the code according to the defined...


My new blog with some vintage content

Introduction As a senior developer I think it is important to share the knowledge, thoughts, and day to day experiences. Attending to conferences, meetups and writing a blog is a great way to achieve this. I was working on this blog, when remembered the early days of my career. Back in 2008 (huh, it was 11 years ago) together with 3 more young and ambitious developers we founded a company. The company itself was not a big success – to put it mildly – but we’ve learned a lot and worked hard these days. No composer, no GitHub Using open...


How to dump all MySQL databases into separate files

Sometimes we need to to dump all databases form a MySQL server. This can be done using the mysqldump utility with the –all-databases switch enabled. In this case mysqldump will dump all databases to the standard output or to a file if explicitly specified. Let’s assume a situation where we want to backup all of the databases from the server, with the possibility to restore only one database at a time. To achieve this, you need to dump all the databases one by one or to use a pre-made script to do the heavylifting for you.  I’ve found a simple...


Flex remoting with CakePHP – CpAmf plugin

The goal of this project was to use CakePHP controllers as flash remoting services. The basic idea was to use AMFPHP 1.9, because we used it before and it was a good choice in earlier projects. As nobody wants to “reinvent the wheel”, I googled for a solution to integrate the AMFPHP into the CakePHP framework. After a short research I found the following solutions: cakeAMFPHP plugin cakeAMF plugin I tried both solutions, but cakeAMFPHP does not use the latest AMFPHP, and with cakeAMF there was a problem using flex RemoteObjects. The idea for my implementation came from cakeAMFPHP. Requirements CakePHP 1.2 AMFPHP...