PHPStorm
PhpStorm Tips, ticks and standard setup
- Tips and Tracks for PHPStorm (PHPStorm Tips and Tricks.md)
- Standard setup for PHP projects (Standard.md)
PhpStorm Tips, ticks and standard setup
<?php // ~/.config/psysh/config.php | |
// Anything not Laravel - let's try to autoload something likely to exist | |
if (!defined('LARAVEL_START')) { | |
return [ | |
'defaultIncludes' => [ | |
getcwd().'/vendor/autoload.php', | |
getcwd().'/bootstrap/autoload.php', | |
], | |
]; |
# Laravel Best Practices | |
Laravel is a PHP framework and just like any other PHP framework there are several ways to get a single thing done in a lot of cases, for conformity these are hand picked best practices. | |
1. Installation of every Laravel project should be done with: | |
```bash | |
composer create-project laravel/laravel {./} or {projectname-backend} | |
``` | |
2. The project name should be in kebab cases in the format: `{projectname-backend}` | |
3. All file names should be in title cases **ProductController, PostService, Category** | |
4. All services should be named after model name if tied to a model, else it should carry the name of the entity, and the suffix 'Service' i.e. {Name}Service |
<?php namespace Vendor\Library; | |
use Another\Vendor\Library\ClassName; | |
abstract class ClassName extends AnotherClass implements Countable, Serializable | |
{ | |
const CONSTANTS = 'top'; | |
use someTrait, anotherTrait { | |
anotherTrait::traitMethod insteadof someTrait; |
Various configuration and alias commands you can directly run from the command line.
Aliases are convenient shotcuts making you everyday work a little easier. This is especially true for commands that you use a lot and thus save you a lot of keystrokes, and for commands that are so long making them hard to remember and tidious to type. When designing an alias I make sure the abbreviation makes sence to me. In that way they are not too cryptic and makes sure I remember them more easily.
However, some commands can rewrite or delete your work. These commands always need your full attention in order to prevent problems. For these kind of commands, an alias should only be made with great consideration.