Skip to main content

19 posts tagged with "php"

View All Tags

API REST - How to write good APIs

10 min read
Christophe
Markdown, WSL and Docker lover ~ PHP developer ~ Insatiable curious.

API REST - How to write good APIs

When developing APIs from scratch, you can do it in the mode I get behind the PC and start programming or I learn about the standards first and then program in compliance with these standards.

And if we lose sight of these norms, we quickly come back to writing endpoints like /articles/insert that are semantically incorrect (and even stupid). In fact, we'll never GET here.

The purpose of the article below is to list best practices by way of examples.

Rector 1.0.0 馃帀馃帀馃帀, my friend, my coach

6 min read
Christophe
Markdown, WSL and Docker lover ~ PHP developer ~ Insatiable curious.

Rector 1.0.0 馃帀馃帀馃帀, my friend, my coach

If there was only one, it would be Rector. Rector is extremely powerful and brilliant and, you know what, it's free!

Rector is a tremendous application to scan and automatically upgrade your codebase to a given version of PHP and this means, too, to inspect how you're coding.

Rector will look at every line of code, every loop, every conditional test, every function, every class in a PHP source code and suggest improvements.

In this role, it will not only detect improvements to my code (like a static analysis tool) but, and this is the biggest advantage for me, it will show me how I can become a better developer.

I REALLY LOVE RECTOR 馃挄

PHP development in a devcontainer with preinstalled code quality tools

22 min read
Christophe
Markdown, WSL and Docker lover ~ PHP developer ~ Insatiable curious.

PHP development in a devcontainer with preinstalled code quality tools

Don't want to read this long article

Let's imagine one of the following situations:

  1. You are working with several people on the same PHP project and you notice that one or other person does not comply with your quality criteria when it comes to the layout of the code. You like to use four spaces for indentation, you want the brace that marks the start of a function to be on the line, you don't want to see any more useless spaces at the end of the line, ... and damned! you notice that some people don't care about this.

  2. You are working alone on a project and don't want to lose time to configure your VSCode experience. You wish to start very quickly with a lot of tools already installed in VSCode so you can put your focus to the code, not the editor.

The ultimate solution: using a devcontainer in VSCode.

By using a devcontainer, you (and your team colleague) will use a preinstalled environment and everyone will have exactly the same. You'll save yourself a lot of time by not having to configure your system, and you'll be able to start coding straight away, supported by a range of quality analysis tools.

Laravel Filament

One min read
Christophe
Markdown, WSL and Docker lover ~ PHP developer ~ Insatiable curious.

Laravel Filament

Filament is a collection of beautiful full-stack components. The perfect starting point for your next app. i.e. a set of free-to-use components and promises that we'll be able to quickly build nice administration interfaces.

The competitor of Filament is the official Laravel Nova which is a paid software.

Filament is built using the latest technologies: the TALL stack. This acronym sums up the technologies used: Tailwind, Alpine, Laravel and Livewire.

Sticky scroll in vscode

One min read
Christophe
Markdown, WSL and Docker lover ~ PHP developer ~ Insatiable curious.

Sticky scroll in vscode

https://dev.to/amrsamy/vs-code-sticky-scroll-2jcd

vscode has recently added a really useful new feature: sticky scroll.

This function allows you to scroll through a document such as a Markdown file, a source code written in PHP or JavaScript or any other supported language and, as you scroll, block contextual information such as the name of the class, the name of the function, the start of the loop, etc. in the upper part of the editor.

Working with Laravel events

5 min read
Christophe
Markdown, WSL and Docker lover ~ PHP developer ~ Insatiable curious.

Working with Laravel events

When I started developing for the Joomla CMS (that was 15 years ago, in 2009), one of the things I liked most was the notion of events.

For example An article is about to be posted, An article has been posted, A user has registered, ... i.e. actions that are announced by the CMS and to which you can react.

When An article is about to be displayed is generated, you can have one (or more) pieces of code interact with this event. You can add dynamic content, you can also deny the article to be displayed if certain conditions are not met.

The easiest way to run a PHP script / website

One min read
Christophe
Markdown, WSL and Docker lover ~ PHP developer ~ Insatiable curious.

The easiest way to run a PHP script / website

The situation: you wish to run a piece of standard PHP code (no dependency) like the one below:

<?php

echo "<h2>Incorrect, silent bug</h2>";

print_r(json_decode(utf8_decode("Ipso lorem"), true));

echo "<h2>Incorrect, we got an exception</h2>";

print_r(json_decode(utf8_decode("Ipso lorem"), true, 512, JSON_THROW_ON_ERROR));