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