RSSAmplifier

Blog

Johannes Pichler's blog about Web Development

Recent content on Johannes Pichler's blog about Web Development

fetzi.devRSS feed ↗39 posts

Latest posts

Crafting Elegant APIs with Laravel

Getting your code ready for PHP 8.5

PHP 8.5 was released about two months ago, so it should be stable enough to upgrade. I generally avoid big-bang releases, especially since I run multiple applications on a single server. To prevent a risky all-at-once upgrade and to verify that everything works correctly before switching PHP versions, I was looking for a way to upgrade the codebase beforehand. Getting ready To prepare an…

Crafting Elegant APIs with Laravel

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 the action configuration such as label, name etc. Now lets look at some example code from Filament 3:…

Battle tested Laravel API design

Battle tested API design

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 retrieve the requested data. But consider the following example: you are loading a certain product…

(Understanding) OAuth2... for real?

Battle tested API design

(Understanding) OAuth2... for real?

(Understanding) OAuth2... for real?

An introduction to Golang

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 for our current product was outdated and some adapted functionality, after a live deploy, did not…

Decouple everything

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 every content page has a unique slug and this slug is used to lookup the page content in the…

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 A or the B version. For example if the cookie exists the user will recieve version A and otherwise…

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 Congress 2018 in Vienna I listened to a talk about json:api by Jeremiah Lee and he mentioned JSON…

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 “watchlist”. This feature is available for guest and of course for logged in users. The key…

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 about his bash function composer-link and I enhanced this command to directly require the package with…

(Understanding) OAuth2... for real?

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 route /user/{user} with a controller method that has an annotated input parameter like User $user…

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 not have a version for PHP 7.x. So I looked for an alternative and found the cloud service…

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 the code base of another team. Almost every team only used one line commits and a few devs used…

Getting more out of Git (german)

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 view and access properties/methods as needed. But if you are consuming multiple differrent data…

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 working on at work. We use a variety of datasources (php api’s, elasticsearch, cache, …) in…

Go for PHP devs

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 encoding part is easy, add the JsonSerializable interface to the model and implement the JsonSerialize…

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 expected. To do so you will push your dev branch to github and reference a new repository in your…

Refactoring to Collections

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 ) { $schedule -> command ( ExampleCommand :: class ) -> everyFiveMinutes () -> appendOutputTo (…

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&rsquo;d like to share my learnings on general testing or phpspec specific fails. An example I would like to look at a pretty simple and very common task. Let&rsquo;s fetch…

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 test case. In this article I will use a very trivial example for a custom matcher. Let&rsquo;s…

Testing with phpspec

Testing a web application can be very challenging. Should tests cover the whole system (frontend, businesslogic, backend, &hellip;) or do you want to test these parts on their own? In this article, I&rsquo;m explaining why I am using phpspec for testing my business logic at the unit level. I&rsquo;ve used xUnit for testing over years now, but I often struggled with some recurring code that exists…

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 listing on page 2 and wants to comment on a certain post. When he clicks on the &ldquo;add…

Talks

About me

Hey, my name is Johannes Pichler. I&rsquo;m working as a Team Lead @ Wimberger Management GmbH in Lasberg, Upper Austria. In my spare time I love to contribute to open source projects like laravel.io and other PHP/Laravel related projects. Based on former experiences I force my team mates and myself to follow a test-driven development approach and to use supportive tools as efficient as possible.

Privacy & Imprint

This page gives you relevant privacy information and of course the imprint for using fetzi.dev. What data is collected? If you sign up for the newsletter on the blog your e-mail address gets stored. How is this data used? Your e-mail address is used to send you a newsletter with the latest blog articles. This is done by using the MailChimp e-mail service. You can find the privacy policy from…

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 configuration change in my nginx config. NGINX Version Upgrade To be able to use HTTP/2 you need at least…