fetzi.dev

Using action classes for table actions in Filament 3

I recently switched a private project from Laravel Nova to Filament 3 and had the problem that defining custom table actions was complicated and the produced code was unreadable, at least for me. I was spoiled by Nova because it provides Action classes that contain the actual action logic and also …

API Caching done right

Especially for web client applications data caching is an important topic. But as an API developer you want to make sure that every type of client can use your caching mechanism to only download data when it is needed and necessary. Ok you may say that if the client requests an endpoint it wants to …

Living documentation for developers

At work we are storing all our technical documents (process descriptions, technical and functional documentations) in Confluence. For developers (and especially me) it is difficult to store technical documents separated from source code. In the past I often got in trouble because the documentation …

Static route parameters in Laravel

Route parameters are a very common approach to pass input data to your controller methods. Laravel provides a lot of different features and possiblities for using route parameters in your application. Recently I had to implement some content pages that are backed by a database table. This means that …

Feature flags in Laravel

Normally A/B split testing is about smaller layout adaptions or simple feature changes. But in some cases a complete rewrite of a feature is necessary and should be compared to the old solution. The normal workflow in our team is to create a feature cookie to determine if the user should recieve the …

Implementing JSON Patch in Laravel

I’ve often struggled with the PATCH request method in the past. Of course it should enable an API user to only send a subpart of the document to update. But I never found a good solution how to implement a PATCH request the works out in all needed cases. Last week at the WeAreDevelopers World …

Executing login protected actions in Laravel

As you may have already noticed I’m working for the biggest job platform in Austria, karriere.at. Naturally our main feature is to provide a fast and reliable job search on our platform and one user feature on the job search is to allow them to add a certain job to their so called …

Add composer-link command for local development

I’ve written a blog post a year ago about developing a composer package locally by using it in another project. To do so you need to setup a local repository configuration in your composer.json file and then require the dependency with composer require. Caleb Porzio has written an article …

Implicit model binding in Slim APIs

In my daily job I’m building resource APIs based on the Slim framework. Our apis use Eloquent for database access and I often miss the convenient functionality of Laravel (called Implicity Binding) to automatically get the corresponding model instance based on a route parameter. For example a …

Profiling PHP applications with XHGui

To profile my php applications I used xdebug in combination with webgrind in the past. Webgrind visualizes the cachegrind files generated by xdebug. This approach is ok but webgrind only contains basic visualization features. After some research I ended up with a tool called Xhprof. But Xhprof does …

Why commit messages matter

A few months ago we published git commit message guidelines at our company. The defined rules are quite the same as the guidelines from Chris Beams. Before this step every development team had its own commit message “standard” and it was hard for developers to lookup some details inside …

Getting rid of view models

In my last article I mentioned that I have to use view models to transform my model data into an array representation that can be used by Handlebars. If you are using the standard Laravel models and blade as view engine you will be fine with just passing on the eloquent models directly into your …

Using Laravel's Responsable Interface

In the next Laravel version 5.5 a new interface called Responseable gets introduced. It is a simple interface that defines one method called toResponse that returns an instance of Illuminate\Http\Response. This new feature is looking really nice. Especially for the project I’m currently …

From JSON to model instances in PHP

JSON is the format I use the most when it comes to data transfer. In almost every case I serialize my data with json_encode and at some point in time I use json_decode to get the data back into a somehow structured format. For example I’m trying to encode/decode a class called Person. The …

Developing composer packages locally

Assume you are creating a new php package that will be shipped via composer/packagist. During development you will use your unit tests for validating the features. But at some point in time you need to include your package in a “real” application to ensure everything is working as …

Monitoring your Laravel Schedule

Getting an overview of your scheduled tasks in Laravel and when they run, can be quite tricky. In your console Kernel class you define your scheduled commands, but you do not get any information about the defined schedules out of the kernel. <?php protected function schedule(Schedule $schedule) …

Common testing fails - testing the right scope

When I started with phpspec I often wrote tests for already existing classes. In the last few weeks I read over some test cases from my phpspec beginnings and some of them really scared me. With this series of blog articles I’d like to share my learnings on general testing or phpspec specific …

Writing custom phpspec matchers

Writing tests is sometimes a hard an time consuming task. Especially if you have functionality that cannot be easily tested with your testing framework. phpspec provides an awesome set of so called matchers. But sometimes the predefined matchers are not useful or suitable for implementing a certain …

Testing with phpspec

Testing a web application can be very challenging. Should tests cover the whole system (frontend, businesslogic, backend, …) or do you want to test these parts on their own? In this article, I’m explaining why I am using phpspec for testing my business logic at the unit level. …

Storing an application's state

Storing the current state of an application is a very difficult task. If you are building an application that is rendering its content on the server side you need to store the application state somehow on the server. A good example for the described situation would be if a user is browsing a blog …

HTTP/2 NOW!

Yesterday I heard a great keynote about the current status of HTTP/2 at the Topconf conference in Linz, Austria. In the evening I tried to upgrade my website to use HTTP/2. Amazingly, I was able to update my webserver within 2 or 3 minutes by executing one software update command and one small …