Development

Further understandings; Learning Laravel week 2

Continuing on from week 1 in learning the Laravel Framework was spent working on a CRUD project.

Doing the routes, views and controller functions for index, show, store, edit, create and update. Joins and counts with the database query builder as well as some Vue Js.

The key points from week 2:

Updating versions

Today Laravel 9 was officially released so I got the experience of updating the core version for a project.

As from the upgrade docs I had to do some composer dependency version switching and then change some namespaces in a middleware file and that was it.

Granted my Laravel project is just a CRUD app, more advanced projects would need a little bit more tinkering however the updating process was easy.

API

Building or incorporating API endpoints in a Laravel project is simple to achieve with just one line in the API routes file.

Route::middleware('auth:api')->get('online/{username}', 'App\Http\Controllers\ApiController@checkUserIsOnline');

Here the endpoint is projectname/api/online/ and the api_token needs to be sent.

Else an open and unrestricted API can be done like

Route::get('status', 'App\Http\Controllers\ApiController@serverStatus');

Packages

Yes, composer packages get used outside of the Laravel ecosystem, yet it seems to me that incorporating packages into Laravel is the norm and something that isn’t going to clog down the project.

More so all of the official Laravel packages (labelled as ecosystem) show how durable and easy it is to build.

Cashier is a subscription billing package, available and easy to implement. Saves you the hassle of building or implementing your own.

Readability

One of the biggest things I have found with Laravel is the readability of code and the structure of the MVC framework is very appealing.

Knowing that the route calls the controller which can invoke a model, finally showing the view.

With Laravel everything has a place, writing OOP with Vanilla PHP gives you all the freedom to have no organisation or consistent logic in code placement.

More learning resources

Another excellent learning resource I have come across is Laravel Daily on YouTube. Aside from videos being posted daily, the ~ several minute long videos are a quick way to gain an oversight on a large coverage of Laravel concepts.

An example of this is shortening store and updating in controllers.

 

 

Share

Recent Posts

Kennington reservoir drained drone images

A drained and empty Kennington reservoir images from a drone in early July 2024. The…

1 year ago

Merrimu Reservoir drone images

Merrimu Reservoir from drone. Click images to view larger.

1 year ago

FTP getting array of file details such as size using PHP

Using FTP and PHP to get an array of file details such as size and…

2 years ago

Creating Laravel form requests

Creating and using Laravel form requests to create cleaner code, separation and reusability for your…

2 years ago

Improving the default Laravel login and register views

Improving the default Laravel login and register views in such a simple manner but making…

2 years ago

Laravel validation for checking if value exists in the database

Laravel validation for checking if a field value exists in the database. The validation rule…

2 years ago