Skip to content

Commit 72f56b6

Browse files
authored
README: Add Pitfalls section
1 parent 39e35aa commit 72f56b6

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

README.md

+42
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ PHP Code compiler - Phar executable compiling utility
1717
- [Install](#install)
1818
- [Requirements](#requirements)
1919
- [Quick install](#quick-install)
20+
- [Pitfalls](#pitfalls)
2021
- [License](#license)
2122

2223
## Usage
@@ -132,6 +133,47 @@ _Add execution permissions to the binary_
132133
chmod +x ${BINDIR}/phpcc
133134
```
134135

136+
## Pitfalls
137+
138+
Here is a (non-exhaustive) list of the most common mistakes related to PHAR compiling.
139+
140+
### Local versus compiled files
141+
142+
Let's consider the following tree (all files required by the app)
143+
144+
```
145+
bin/acme.php
146+
src/Command/Acme.php
147+
src/Command/SomeClass.php
148+
lib/Ufo.php
149+
```
150+
151+
Compile it (Oops... one Unknown File Object has not been included)
152+
153+
```
154+
phpcc -e bin/acme.php -f bin/acme.php -d src/ -o bin/acme
155+
```
156+
157+
Guess what ?
158+
159+
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.
160+
161+
### Size too big
162+
163+
Many projects include some dev libraries, for unit test, local data seeding or code inspection.
164+
165+
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**.
166+
167+
Q: How do we remediate then ?
168+
169+
A: Before compiling, we ensure the `vendor` directory does not contains any dev library:
170+
171+
```
172+
composer install --no-dev
173+
phpcc -e bin/acme.php -f bin/acme.php -d src/:php -d vendor:php -d vendor:yaml -o bin/acme
174+
```
175+
176+
135177
## License
136178

137179
Licensed under the [MIT License](LICENSE).

0 commit comments

Comments
 (0)