Blog

Welcome to the Dev-Blog! Here, I regularly share valuable tips, useful tricks, and helpful tutorials from the world of web design. With a focus on PHP, Laravel, Statamic, and web development in general, I aim to help you expand your knowledge.

macOS

Disabling the Delay of the macOS Dock Fade-in

Since windows in macOS cannot overlap the Dock, hiding the Dock often provides an effective way to gain additional screen space. This can be particularly helpful for smaller screens. Unfortunately, a delay always occurs until the Dock reappears when moving the mouse close to it. Fortunately, many hidden settings in macOS can be altered using a command line utility named defaults. To trigger the Dock's fade-in animation instantly, hence completely disabling the delay, you have to enter the follow

Sebastian Widmann

Sebastian Widmann

Webdesigner / Web developer

Laravel

Fixing XML Issue in Blade Templates

During my latest project, I dynamically created an XML sitemap for search engines using Laravel. However, while rendering the Blade template, I encountered the following error message: syntax error, unexpected identifier "version" The root cause of this issue can be traced back to PHP potentially interpreting what's known as "Short Open Tags". PHP code typically begins with <?php. However, when Short Open Tags are enabled, <? is sufficient, which can lead to a conflict

Sebastian Widmann

Sebastian Widmann

Webdesigner / Web developer

Development

New Features of PHP 8.3

PHP 8.3 is set to be released on November 23, 2023. The following are the innovations and changes that PHP 8.3 will bring - each with links to further information. Typed Class Constants Now you can define a data type for a class constant with typed class constants. This makes your code more secure and cleaner. The json_validate Function The json_validate function is a novelty that allows validating a JSON string and receiving helpful and accurate error messages in the process. Dynamic Class Cons

Sebastian Widmann

Sebastian Widmann

Webdesigner / Web developer

Laravel

New Features in Laravel 11: What Web Developers Need to Know

This article provides information about the upcoming changes in Laravel 11. Please note that this is still a beta preview and changes are possible at any time. The article will be updated as new information or changes are known. Simplified Directory Structure One of the first things you'll notice is the revised and simplified directory structure of Laravel. By default, controllers no longer extend anything and the middleware directory has disappeared. Laravel currently includes nine middleware,

Sebastian Widmann

Sebastian Widmann

Webdesigner / Web developer

Laravel

Increase PHP Memory Limit when using Laravel Herd

Since the release, I have been a user of Laravel Herd. Previously, I used Laravel Valet, but Herd (in combination with dbngin) simplifies the deployment of a Laravel development environment on macOS even further. However, when first running pestphp tests, I encountered a problem: php artisan test -p led to the following error message: ..................................................... In WorkerCrashedException.php line 41:

Sebastian Widmann

Sebastian Widmann

Webdesigner / Web developer

Statamic

Code Examples for Statamic Navigation Structures

Navigation structures in Statamic offer the ability to construct complex page trees with pages and subpages. The following code examples will assist in maintaining and creating these structures. Reset Structure To reset the entire structure of a page, the following code can be used: use Statamic\Facades\Collection; $structure = Collection::findByHandle("pages")->structure(); $tree = $structure->in("de"); $tree->delete(); This code would reset the structure of the d

Sebastian Widmann

Sebastian Widmann

Webdesigner / Web developer

Statamic

Example of Statamic Search via PHP Code

This article explains how to utilize the search function in the CMS Statamic using PHP code. Let's take a look at the following code example: use Statamic\Facades\Search; $builder = Search::index('default') ->ensureExists() ->search('This is my search query') ->where('status', 'published'); $results = $builder->limit(5)->get(); foreach ($results as $result) { echo $result->getCpTitle().PHP_EOL; } First, we initialize the search, set the search index to defau

Sebastian Widmann

Sebastian Widmann

Webdesigner / Web developer

macOS

Clearing DNS Cache on macOS

Have you ever heard of DNS? DNS stands for Domain Name System, and it's something like the phone book of the Internet. It translates the human-readable web addresses that we enter into our browser into the numeric IP addresses that computers use to communicate with each other. In most cases, we don't even notice that our computer is performing this process in the background. But sometimes, problems with the DNS cache, such as outdated or faulty data, can lead to connection problems. In such case

Sebastian Widmann

Sebastian Widmann

Webdesigner / Web developer

Linux

Get public IP address from Linux command line

To get the public IP of a computer or server on a Linux command line, you can use the following command for IPV4 addresses: curl ipinfo.io/ip You can obtain extended information about the IPV4 address (as JSON) via: curl ipinfo.io If you want to find out the public IPv6 address instead, you can use the following command: curl v6.ipinfo.io/ip For IPv6, you can also get the extended information via: curl v6.ipinfo.io

Sebastian Widmann

Sebastian Widmann

Webdesigner / Web developer

Statamic

Code Examples for Statamic Entries

Query all entries of a collection use Statamic\Facades\Entry; Entry::query()->where("collection", "posts")->get(); In this example, the Entry facade of Statamic is used to query all entries (entries) in a specific collection (collection). Here, all entries of the posts collection are searched for. The get() method executes the query and returns the results. Query all entries of a user in a collection use Statamic\Facades\Entry; use Statamic\Facades\User; $author = Us

Sebastian Widmann

Sebastian Widmann

Webdesigner / Web developer