You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-[Shebang line in main script](#shebang-line-in-main-script)
23
+
-[Local versus compiled files: missing file](#local-versus-compiled-files-missing-file)
24
+
-[Local versus compiled files: name collision](#local-versus-compiled-files-name-collision)
25
+
-[Size too big](#size-too-big)
21
26
-[License](#license)
22
27
23
28
## Usage
@@ -177,6 +182,100 @@ jobs:
177
182
run: bin/acme --version
178
183
```
179
184
185
+
## Pitfalls
186
+
187
+
Here is a (non-exhaustive) list of the most common mistakes related to PHAR compiling.
188
+
189
+
### Shebang line in main script
190
+
191
+
Since the main (entrypoint) script will be **included** in the PHAR stub, it must not contain any shebang line, otherwise this line will be treated as text and printed to standard output when invoking the compiled PHAR.
192
+
193
+
_Example: Invoking a version of `phpcc` compiled with a shebang line in `bin/compile.php`_
194
+
195
+
```
196
+
$ bin/phpcc --version
197
+
#!/usr/bin/env php
198
+
PHP Code Compiler version 1.3.0-dev
199
+
```
200
+
201
+
### Local versus compiled files: missing file
202
+
203
+
Let's consider the following tree (all files required by the app)
204
+
205
+
```
206
+
bin/acme.php
207
+
src/Command/Acme.php
208
+
src/Command/SomeClass.php
209
+
lib/Ufo.php
210
+
```
211
+
212
+
Compile it (Oops... one Unknown File Object has not been included)
Many projects include some dev libraries, for unit test, local data seeding or code inspection.
266
+
267
+
Fact is, some of those libs have **A LOT** of dependencies... Hence the `vendor` directory, which is usually included in the archive is really **HUGE**.
268
+
269
+
Q: How to remediate then ?
270
+
271
+
A: Before compiling, ensure the `vendor` directory does not contains any dev library:
0 commit comments