Tuesday, 25 February 2025

Laravel 12, CSS and the Brave web browser

 I just started using the new version of Laravel (version 12)

I created a new project using the Livewire starter kit.

The installation process worked quite well.

I then changed to the new directory and ran:

composer run dev

I use Herd and was given a local URL

I put the URL in my chosen web browser, Brave.

The welcome page came up just fine, with a couple of options for login and register.

I opted to register, but the registration page had no styling.

I then realised that the app.css and a couple of other files were being blocked by the browser.

I put the shields down for the new URL and everything worked.

Nothing had gone wrong with the installation at all.

Something to watch out for folks.

Thursday, 20 February 2025

Custom logging in Laravel 11

 It's often difficult to see what's going on in your code. Many people have difficulty setting up debugging or even if they have, following through the break points. Commonly developers try to resolve this through:

dd

or

var_dump

Another feature which can be used to help in this process is logging. Laravel holds a very good feature to support this. Imagine you are adding a feature called "indeed" and you want to log the progress of your application through it's data points.

You can open up the file:

config/logging.php

and add lines like these:

'channels' => [

    // Other channels...

    'indeed' => [

        'driver' => 'single',

        'path' => storage_path('logs/indeed.log'),

        'level' => 'info',

    ],

],

Now you can add a line like this to your code within the "indeed" feature:

Log::channel('indeed')->info('This is a custom log message');

Look inside the directory:

storage/logs

You will see a file called indeed.log containing your output.