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.
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.