Highlight code syntax on README document

This commit is contained in:
Thach Nguyen
2018-01-31 20:10:23 +07:00
parent 1080504a78
commit 66d6e3df01
+24 -2
View File
@@ -18,13 +18,16 @@ Note: You do need CodeIntel for Sublime Text: https://github.com/SublimeCodeInte
It's possible to generate a PhpStorm meta file, to [add support for factory design pattern](https://confluence.jetbrains.com/display/PhpStorm/PhpStorm+Advanced+Metadata). For Laravel, this means we can make PhpStorm understand what kind of object we are resolving from the IoC Container. For example, `events` will return ann `Illuminate\Events\Dispatcher` object, so with the meta file you can call `app('events')` and it will autocomplete the Dispatcher methods.
```bash
php artisan ide-helper:meta
```
```php
app('events')->fire();
\App::make('events')->fire();
/** @var \Illuminate\Foundation\Application $app */
$app->make('events')->fire();
```
Pre-generated example: https://gist.github.com/barryvdh/bb6ffc5d11e0a75dba67
@@ -34,20 +37,27 @@ Pre-generated example: https://gist.github.com/barryvdh/bb6ffc5d11e0a75dba67
Require this package with composer using the following command:
```bash
composer require barryvdh/laravel-ide-helper ~1.11
```
After updating composer, add the ServiceProvider to the providers array in `app/config/app.php`
```php
'Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider',
```
You can now re-generate the docs yourself (for future updates) in artisan
```bash
php artisan ide-helper:generate
```
Note: bootstrap/compiled.php has to be cleared first, so run `php artisan clear-compiled` before generating (and `php artisan optimize` after..)
You can configure your composer.json to do this after each commit:
```json
"scripts":{
"post-update-cmd":[
"php artisan clear-compiled",
@@ -55,10 +65,13 @@ You can configure your composer.json to do this after each commit:
"php artisan optimize"
]
},
```
You can also publish the config-file to change implementations (ie. interface to specific class) or set defaults for --helpers or --sublime.
```bash
php artisan config:publish barryvdh/laravel-ide-helper
```
The generator tries to identify the real class, but if it cannot be found, you can define it in the config file.
@@ -78,8 +91,10 @@ Please make sure to backup your models, before writing the info.
It should keep the existing comments and only append new properties/methods. The existing phpdoc is replaced, or added if not found.
With the `--reset (-R)` option, the existing phpdocs are ignored, only the newly found columns/relations are saved as phpdocs.
```bash
php artisan ide-helper:models Post
```
```php
/**
* An Eloquent Model: 'Post'
*
@@ -92,20 +107,27 @@ With the `--reset (-R)` option, the existing phpdocs are ignored, only the newly
* @property-read \User $author
* @property-read \Illuminate\Database\Eloquent\Collection|\Comment[] $comments
*/
```
By default, models in app/models are scanned. The optional argument tells what models to use (also outside app/models).
```bash
php artisan ide-helper:models Post User
```
You can also scan a different directory, using the --dir option (relative from the base path):
```bash
php artisan ide-helper:models --dir="app/workbench/name/package/models" --dir="app/src/Model"
```
You can publish the config file (`php artisan config:publish barryvdh/laravel-ide-helper`) and set the default directories.
Models can be ignored using the --ignore (-I) option
```bash
php artisan ide-helper:models --ignore="Post,User"
```
Note: With namespaces, wrap your model name in " signs: `php artisan ide-helper:models "API\User"`, or escape the slashes (`Api\\User`)