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
@@ -132,6 +133,59 @@ _Add execution permissions to the binary_
132
133
chmod +x ${BINDIR}/phpcc
133
134
```
134
135
136
+
## Pitfalls
137
+
138
+
Here is a (non-exhaustive) list of the most common mistakes related to PHAR compiling.
139
+
140
+
### Shebang line in main script
141
+
142
+
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.
143
+
144
+
_Example: Invoking a version of `phpcc` compiled with a shebang line in `bin/compile.php`_
145
+
146
+
```
147
+
$ bin/phpcc --version
148
+
#!/usr/bin/env php
149
+
PHP Code Compiler version 1.3.0-dev
150
+
```
151
+
152
+
### Local versus compiled files
153
+
154
+
Let's consider the following tree (all files required by the app)
155
+
156
+
```
157
+
bin/acme.php
158
+
src/Command/Acme.php
159
+
src/Command/SomeClass.php
160
+
lib/Ufo.php
161
+
```
162
+
163
+
Compile it (Oops... one Unknown File Object has not been included)
If the `bin/acme` compiled archive stays in its place, it won't fail, because `lib/Ufo.php` can still be found from its point of view.
172
+
173
+
### Size too big
174
+
175
+
Many projects include some dev libraries, for unit test, local data seeding or code inspection.
176
+
177
+
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**.
178
+
179
+
Q: How do we remediate then ?
180
+
181
+
A: Before compiling, we ensure the `vendor` directory does not contains any dev library:
0 commit comments