File tree Expand file tree Collapse file tree 1 file changed +30
-1
lines changed Expand file tree Collapse file tree 1 file changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -173,12 +173,19 @@ Compile it (Oops... one Unknown File Object has not been included)
173173phpcc -e bin/acme.php -f bin/acme.php -d src/ -o bin/acme
174174```
175175
176+ ##### Problem
177+
176178Launching the ` bin/acme ` compiled archive should raise an error because of the missing file.
177179
178180Well...not. What happens here then ?
179181
180182If the ` bin/acme ` compiled archive stays in its place,the ` lib/Ufo.php ` can still be found from its point of view.
181183
184+ ##### Solution
185+
186+ Always move the compiled executable ** out** of the project's working directory before testing it.
187+
188+
182189#### Trap 2: different files with the same relative path
183190
184191Eg:
187194require "vendor/autoload.php"
188195```
189196
190- TODO: explain, give workaround
197+ Chances are, there might be such a ` vendor/autoload.php ` file in the project to be compiled.
198+
199+ ##### Problem
200+
201+ From the compiled app point of view, ` vendor/autoload.php ` refers to a relative path in the PHAR archive.
202+
203+ ##### Workaround
204+
205+ The phpcc execution dir (i.e the compiled project's top directory) must be added first in the include path.
206+
207+ For example in the main entrypoint script:
208+
209+ ``` php
210+ // bin/main.php
211+
212+ // ensure we load the execution directory's autoload, not the
213+ // one included in the compiled phar executable
214+ set_include_path(getcwd() . PATH_SEPARATOR . get_include_path());
215+
216+ require 'vendor/autoload.php';
217+
218+ // ...
219+ ```
191220
192221### Size too big
193222
You can’t perform that action at this time.
0 commit comments