GithubHelp home page GithubHelp logo

Comments (10)

katanacrimson avatar katanacrimson commented on September 18, 2024

@hopeseekr tried adding the shebang within the stub file?

from phar-util.

hopeseekr avatar hopeseekr commented on September 18, 2024

Where is the stub file?

from phar-util.

katanacrimson avatar katanacrimson commented on September 18, 2024

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.

hopeseekr avatar hopeseekr commented on September 18, 2024

What I did was

  1. Make a phar via phar-build.
  2. Copy the phar file to stub.php.
  3. Edit stub.php and remove everything below __HALT_COMPILER();
  4. Add #!/bin/env php to the top of stub.php.
  5. Rebuild the phar with the new stub.
  6. chmod 0755 myapp.phar
  7. mv myapp.phar myapp
  8. 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.

katanacrimson avatar katanacrimson commented on September 18, 2024

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.

hopeseekr avatar hopeseekr commented on September 18, 2024

When the empty stub method, no code gets executed... I need the index.php to get executed.

from phar-util.

katanacrimson avatar katanacrimson commented on September 18, 2024

So, wait, are you renaming the phar file to something like index.php, and trying to run it like that?

from phar-util.

hopeseekr avatar hopeseekr commented on September 18, 2024

Nah nothing like that. Code just doesn't run when I use the empty stub you provided...

from phar-util.

katanacrimson avatar katanacrimson commented on September 18, 2024

...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.

hopeseekr avatar hopeseekr commented on September 18, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.