Comments (10)
@hopeseekr tried adding the shebang within the stub file?
from phar-util.
Where is the stub file?
from phar-util.
try: phar-build --help
You're looking for the -S
flag (long form: --stub $stub
).
For more information on stub files:
http://us3.php.net/manual/en/phar.setstub.php
http://us3.php.net/manual/en/phar.fileformat.stub.php
from phar-util.
What I did was
- Make a phar via phar-build.
- Copy the phar file to stub.php.
- Edit stub.php and remove everything below __HALT_COMPILER();
- Add #!/bin/env php to the top of stub.php.
- Rebuild the phar with the new stub.
- chmod 0755 myapp.phar
- mv myapp.phar myapp
- mv myapp.phar.pubkey myapp.pubkey
I have fortunately incorporated this into a Makefile. Unfortunately, 8 steps seems like way too much.
Also, how would you go about tar'ing or zipping up the phar?
from phar-util.
Unless you're looking to keep using the default PHP stub file, you don't need to do anything weird like building a phar and then rebuilding it afterwards.
As far as tarballing or zipping, you can't have them compressed in a deployed state - php needs to include it directly, uncompressed, and if you wanted to use phar's internal compression methods, you lose OpenSSL signing (it's a bug within phar itself, as when you use compression it silently falls back to one of the sha checksums - I believe @koto noted this in one of his blog posts about phar).
Like you, I ended up setting up a makefile to handle phar creation, anyways. You can probably get away with something similar:
#
# sierra makefile
#
PROJECT = sierra
RELEASE_DIR = .
PRIVKEY = ./cert/priv.pem
PUBKEY = ./cert/pub.pem
# target: all - default target, does nothing
all :
+@echo "no target specified, try 'make help'"
# target: deploy - prepares a deployable build
deploy: groups version core twig-phar mail-phar pack-all
# target: core - builds main phar
core:
echo "<?php __HALT_COMPILER();" > stub.php; \
phar-build --phar $(PROJECT).phar -s ./includes/ -x "\.txt$$ \.xml.*$$ \.markdown$$ \.md$$ stub\.php \.json$$ \.rst$$ \.test$$ ~$$ README\.* CHANGE(LOG|S)\.* AUTHORS.\* LICENSE\.* \.gitignore" -X "/\.git/ /\.svn/ /test/ /bin/ /doc/ /swiftmailer/ /Twig/" -S stub.php -p $(PRIVKEY) -P $(PUBKEY) --strip-files ".php$$"; \
mv $(PROJECT).phar* lib/; \
echo "built core phar"; \
rm stub.php
(note: I've omitted what isn't relevant from my own makefile - adapt this to your own needs)
I imagine you can modify the line that creates stub.php to use something a bit different, have it include a shebang.
from phar-util.
When the empty stub method, no code gets executed... I need the index.php to get executed.
from phar-util.
So, wait, are you renaming the phar file to something like index.php, and trying to run it like that?
from phar-util.
Nah nothing like that. Code just doesn't run when I use the empty stub you provided...
from phar-util.
...Are you providing it anything in the stub? Are you including the __HALT_COMPILER() call? This might be the phar erroring out for some reason - be sure that you've got error_reporting cranked all the way up.
from phar-util.
This was the first issue I ever created on GitHub. And I have no idea hwat I was trying to accomplish :o
from phar-util.
Related Issues (13)
- Use exit call on error? HOT 1
- phar-build encounters fatal error after commit 1865248c18704731b55302b4044e7614136629cd HOT 7
- phar-build HOT 1
- phar-build always want to sign phar package HOT 1
- Comment stripping from files HOT 3
- RemotePharVerifier method "assertVerified" has borked docs
- error in condition in file RemotePharVerifier HOT 2
- RemotePharVerifier.php has a syntax error in 0.6.1 HOT 4
- Several test cases fail with errors
- Phar with Encryption
- Verify public key
- Pear channel/domain doesn't exist anymore HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from phar-util.