Laravel文件路径

问题描述:

I am using laravel 4.2. I am following this basic tutorial on how to build Laravel Commands. I want to know where laravel is defining or registering the file paths to. For e.g.

use Illuminate\Console\Command;

is actually refering to the path below

vendor\laravel\framework\src\Illuminate\Console\Command.php

I am new to laravel, If you could point me to the right direction it would greatly help me.

我正在使用laravel 4.2。 我正在关注如何构建 Laravel命令。 我想知道laravel在哪里定义或注册文件路径。 例如 p>

使用Illuminate \ Console \ Command; p> blockquote>

实际上是指向下面的路径

vendor \ laravel \ framework \ src \ Illuminate \ Console \ Command.php p> blockquote>

我是新手 laravel,如果你能指出我正确的方向,那将对我有很大帮助。 p> div>

So I studied how it locates the file it was using. Then I found out it is using a namespace. The book called CODE BRIGHT by Dayle Rees greatly helped me in understanding how namespacing works. You can scroll down under the section called THE PRIMERS where Dayle describes how it functions. It is easy to understand! Give it a try.

there are two files you need to look at under app/config one is start.php this register the basic path for the laravel source files the base path . "/vendor/laravel/framework/src" .

the second one is app.php which provide an aliases array that correspond to the source classes and files.

for instance if you want to know where the class eloquent that your models are extending is at, you need to go to app.php see that Eloquent alias points toward 'Illuminate\Database\Eloquent\Model' and concat the path from start.php so it will be at \web\yourproject\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php

config.php holds the rest of the mapping.