Skip to content

Developer Remarks | Know & How

Posts

Laravel - how to deploy code changes on hosted server

It is recommended to do an initial installation on hosted server without all dev packages and tools. The best approach is to prepare a local docker installation where it is possible to run composer and NPM. For this purpose, we can use an intermediate server for clean code generation in PHP and css/js. The server is also used for final testing of the application before a transfer of cleaned code to the live server. In order to have the closest possible conditions for running the application on the...
Read More
deployment

Laravel Blade using custom class

Custom Helpers Several possibilities: https://stackoverflow.com/questions/57560226/how-to-use-class-from-blade-template Sometimes, it's necessary to have custom PHP code used in Laravel blade files. (Tools ObsidianBook). Using custom facade (for short simple helpers NOT recommended) Using alias in config/app Helper code created by developer is best located in classes using namespace App\Helpers or App\Services. Custom Helper class is included in config/app.php Class Aliases, e.g. 'Helper' =>...
Read More
blade

Laravel Best Practices

Note created on: 2023-05-05 07:45 Single responsibility principle A class and a method should have responsibility. Bad: public function getFullNameAttribute(): string { if (auth()->user() && auth()->user()->hasRole('client') && auth()->user()->isVerified()) { return 'Mr. ' . $this->first_name . ' ' . $this->middle_name . ' ' . $this->last_name; } else { return $this->first_name[0] . '. ' . $this->last_name; ...
Read More
laravel