#### For Laravel 4.x, check version 1.11
#### Complete phpDocs, directly from the source
> 項目地址:https://github.com/barryvdh/laravel-ide-helper
Checkout this Laracasts video for a quick introduction/explanation!
This package generates a file that your IDE understands, so it can provide accurate autocompletion. Generation is done based on the files in your project, so they are always up-to-date. If you don't want to generate it, you can add a pre-generated file to the root folder of your Laravel project (but this isn't as up-to-date as self generated files).
* Generated version: https://gist.github.com/barryvdh/5227822
> Note: You do need CodeIntel for Sublime Text: https://github.com/SublimeCodeIntel/SublimeCodeIntel
## New: PhpStorm Meta for Container instances
It's possible to generate a PhpStorm meta file, to add support for factory design pattern. 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 an Illuminate\Events\Dispatcher object, so with the meta file you can call app('events') and it will autocomplete the Dispatcher methods.
~~~
php artisan ide-helper:meta
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
> Note: You might need to restart PhpStorm and make sure .phpstorm.meta.php is indexed. Note: When you receive a FatalException about a class that is not found, check your config (for example, remove S3 as cloud driver when you don't have S3 configured. Remove Redis ServiceProvider when you don't use it).
## Automatic phpDoc generation for Laravel Facades
Require this package with composer using the following command:
~~~
composer require barryvdh/laravel-ide-helper
~~~
After updating composer, add the service provider to the providers array in `config/app.php`
~~~
'Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider',
~~~
You can now re-generate the docs yourself (for future updates)
~~~
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:
~~~
"scripts":{
"post-update-cmd": [
"php artisan clear-compiled",
"php artisan ide-helper:generate",
"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`.
~~~
php artisan vendor:publish --provider=barryvdh/laravel-ide-helper --tag=config
~~~
The generator tries to identify the real class, but if it cannot be found, you can define it in the config file.
Some classes need a working database connection. If you do not have a default working connection, some facades will not be included. You can use an in-memory SQLite driver, using the -M option.
You can choose to include helper files. This is not enabled by default, but you can override it with the --helpers (-H) option. The Illuminate/Support/helpers.php is already set-up, but you can add/remove your own files in the config file.
Automatic phpDocs for models
> You need to require doctrine/dbal: ~2.3 in your own composer.json to get database columns.
If you don't want to write your properties yourself, you can use the command php artisan ide-helper:models to generate phpDocs, based on table columns, relations and getters/setters. You can write the comments directly to your Model file, using the `--write (-W)` option. By default, you are asked to overwrite or write to a separate file (_ide_helper_models.php). You can force No with `--nowrite (-N)`. 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, and only the newly found columns/relations are saved as phpdocs.
~~~
php artisan ide-helper:models Post
/**
* An Eloquent Model: 'Post'
*
* @property integer $id
* @property integer $author_id
* @property string $title
* @property string $text
* @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at
* @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).
~~~
php artisan ide-helper:models Post User
~~~
You can also scan a different directory, using the `--dir` option (relative from the base path):
~~~
php artisan ide-helper:models --dir="path/to/models" --dir="app/src/Model"
~~~
You can publish the config file (`php artisan vendor:publish`) and set the default directories.
Models can be ignored using the --ignore (-I) option
~~~
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)
- 前言
- 發行說明/L5新特性
- 升級向導
- 升級到 5.0.16
- 從 4.2 升級到 5.0
- 從 4.1 升級到 4.2
- 從 4.1.x 升級到 4.1.29
- 從 4.1.25 升級到 4.1.26
- 從 4.0 升級到 4.1
- 貢獻向導
- 環境配置
- 安裝
- 配置
- 基本功能
- 路由
- 基本路由
- CSRF 保護
- 方法欺騙
- 路由參數
- 命名路由
- 路由群組
- 路由模型綁定
- 拋出 404 錯誤
- 中間件
- 建立中間件
- 注冊中間件
- 可終止中間件
- 控制器
- 基礎控制器
- 控制器中間件
- 隱式控制器
- RESTful 資源控制器
- 請求
- 取得請求實例
- 取得輸入數據
- 舊輸入數據
- Cookies
- 上傳文件
- 其他的請求信息
- 響應
- 基本響應
- 重定向
- 其他響應
- 響應宏
- 系統架構
- 服務提供者
- 基本提供者例子
- 注冊提供者
- 緩載提供者
- 服務容器
- 基本用法
- 將接口綁定到實現
- 上下文綁定
- 標簽
- 實際應用
- 容器事件
- 參考:理解PHP 依賴注入|Laravel IoC容器
- Contracts
- 為什么用 Contracts
- Contract 參考
- 如何使用 Contracts
- Facades
- 實際用法
- 建立 Facades
- 模擬 Facades
- Facade 類參考
- 請求的生命周期
- 生命周期概要
- 聚焦于服務提供者
- 應用程序結構
- 根目錄
- App 目錄
- 為應用程序配置命名空間
- 系統服務
- 認證
- 用戶認證
- 取得經過認證的用戶
- 保護路由
- HTTP 基本認證
- 忘記密碼與重設
- 第三方登陸認證
- 交易
- 配置文件
- 訂購方案
- 一次性付款
- Single Charges
- 免信用卡試用
- 訂購轉換
- 訂購數量
- 取消訂購
- 恢復訂購
- 確認訂購狀態
- 處理失敗訂閱
- 處理其它 Stripe Webhooks
- 收據
- 緩存
- 配置
- 緩存用法
- 遞增與遞減
- 緩存標簽
- 緩存事件
- 數據庫緩存
- 集合
- Command Bus
- 建立命令
- 調用命令
- 命令隊列
- 命令管道
- 核心擴展
- 管理者和工廠
- 緩存
- Session
- 認證
- 基于服務容器的擴展
- Laravel Elixir
- 安裝與配置
- 使用方式
- Gulp
- Custom Tasks and Extensions
- 加密
- Envoy 任務執行器
- 安裝
- 執行任務
- 多服務器
- 并行執行
- 任務宏
- 通知
- 更新 Envoy
- 錯誤與日志
- 配置
- 錯誤處理
- HTTP 異常
- 日志
- 事件
- 基本用法
- 事件處理隊列
- 事件訂閱者
- 文件系統與云存儲
- 配置文件
- 基本用法
- 自定義文件系統
- 哈希
- 基本用法
- 輔助方法
- 數組
- 路徑
- 路由
- 字符串
- 網址(URL)
- 其他
- 本地化
- 語言文件
- 基本用法
- 復數
- 驗證
- 覆寫擴展包的語言文件
- 郵件
- 配置
- 基本用法
- 內嵌附件
- 郵件隊列
- 郵件與本地端開發
- 擴展包開發
- 視圖
- 語言
- 配置文件
- 公共資源
- 發布分類文件
- 路由
- 分頁
- 配置
- 使用
- 追加分頁鏈接
- 轉換至 JSON
- 隊列
- 設置
- 基本用法
- 隊列閉包
- 執行一個隊列監聽
- 常駐隊列處理器
- 推送隊列
- 已失敗的工作
- 會話
- 配置
- 使用 Session
- 暫存數據(Flash Data)
- 數據庫 Sessions
- Session 驅動
- 模板
- Blade 模板
- Blade 控制語法結構
- Blade 擴展
- 參考:@section與@yield 介紹
- 單元測試
- 定義并執行測試
- 測試環境
- 從測試調用路由
- 模擬 Facades
- 框架 Assertions
- 輔助方法
- 重置應用程序
- 表單驗證
- 基本用法
- 控制器驗證
- 表單請求驗證
- 使用錯誤信息
- 錯誤信息 & 視圖
- 可用驗證規則
- 條件驗證規則
- 自定義錯誤信息
- 自定義驗證規則
- 數據庫
- 使用基礎
- 配置
- 讀取/寫入連接
- 執行查找
- 數據庫事務處理
- 獲取連接
- 日志記錄
- 查詢構造器
- Selects
- Joins
- 高級 Wheres
- 聚合
- 原生表達式
- 添加
- 更新
- 刪除
- Unions
- 悲觀鎖定 (Pessimistic Locking)
- Eloquent ORM
- 基本用法
- 批量賦值
- 新增,更新,刪除
- 軟刪除
- 時間戳
- 范圍查詢
- Global Scopes
- 關聯
- 關聯查詢
- 預載入
- 新增關聯模型
- 更新上層時間戳
- 使用樞紐表
- 集合
- 獲取器和修改器
- 日期轉換器
- 屬性類型轉換
- 模型事件
- 模型觀察者
- 模型 URL 生成
- 轉換成數組 / JSON
- 結構生成器
- 建立與刪除數據表
- 加入字段
- 修改字段
- 修改字段名稱
- 移除字段
- 檢查是否存在
- 加入索引
- 外鍵
- 移除索引
- 移除時間戳記和軟刪除
- 保存引擎
- 遷移和數據填充
- 建立遷移文件
- 執行遷移
- 回滾遷移
- 數據填充
- Redis
- 配置
- 使用方式
- 管道
- 開發包
- Confide 用戶身份認證
- Entrust 權限管理
- Shoppingcart 購物車
- Genertators 代碼生成工具
- IDE Helper IDE助手
- Artisan 命令行工具
- 概覽
- 用法
- 在命令行接口以外的地方調用命令
- 定時調用 Artisan 命令
- 開發
- 建立自定義命令
- 注冊自定義命令