1 | <?php |
||
9 | class Blueprint extends \Illuminate\Database\Schema\Blueprint |
||
10 | { |
||
11 | /** |
||
12 | * Create a new schema blueprint. |
||
13 | * |
||
14 | * @param Connection $connection |
||
15 | * @param string $table |
||
16 | */ |
||
17 | public function __construct(Connection $connection, $table) |
||
22 | |||
23 | /** |
||
24 | * Execute the blueprint against the database. |
||
25 | * |
||
26 | * @param \Illuminate\Database\Connection $connection |
||
27 | * @param \Illuminate\Database\Schema\Grammars\Grammar $grammar |
||
28 | * |
||
29 | * @return void |
||
30 | */ |
||
31 | public function build(Connection $connection, Grammar $grammar) |
||
34 | |||
35 | /** |
||
36 | * Indicate that the table needs to be created. |
||
37 | * |
||
38 | * @return bool |
||
39 | */ |
||
40 | public function create() |
||
46 | |||
47 | /** |
||
48 | * Indicate that the collection should be dropped. |
||
49 | * |
||
50 | * @return bool |
||
51 | */ |
||
52 | public function drop() |
||
58 | |||
59 | /** |
||
60 | * Specify an index for the collection. |
||
61 | * |
||
62 | * @param string $column |
||
63 | * @param mixed $options |
||
64 | * |
||
65 | * @return Blueprint |
||
66 | */ |
||
67 | public function index($columns, $name = NULL, $algorithm = NULL) |
||
76 | } |
||
77 |
Let’s assume that you have a directory layout like this:
and let’s assume the following content of
Bar.php
:If both files
OtherDir/Foo.php
andSomeDir/Foo.php
are loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php
However, as
OtherDir/Foo.php
does not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php
, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: