phar

How to properly require a phar file

放肆的年华 提交于 2019-12-10 21:33:05
问题 phpunit has stopped supporting PEAR installation. This has caused us to need to use the phar installation of phpunit moving forward. We have a wrapping script that iterates through many directories and calls the phpunit executable on those directories. The wrapping script then consolidates all of the generated reports into a single report. When phpunit was installed with PEAR, the only require we needed at the top of the wrapping script was require 'PHP/CodeCoverage/Autoload.php'; Then, when

Not able to run composer.phar

徘徊边缘 提交于 2019-12-10 13:33:22
问题 Composer is a tool for dependency management in PHP projects. It allows you to declare the dependent libraries your project needs and it will install them in your project for you. Composer is not a package manager. I told this to declare my meaning from Composer . Recently I have tried to run my first Google API project. There is a quickStart witch tells I need to use Composer . So I tried to run composer using php composer.phar install , but the only output I got was some question marks ????

how to get a .phar file real directory within the phar file code?

假如想象 提交于 2019-12-10 13:06:50
问题 I am trying to create a php executable (a phar file) for generating some files, and I would like to know how to get the real path of the phar file (within the phar file code). What I want to do is to create a folder in the same level of the phar file and create the new files there, but realpath(__DIR__.'/../') does not seem to work. Thanks 回答1: As shown in https://stackoverflow.com/a/28775172/282601 the __FILE__ constant has the full path with the scheme: phar:///home/cweiske/Dev/test/phar

Please explain how to create PHP's Phar stubs

[亡魂溺海] 提交于 2019-12-09 05:08:46
问题 I'm trying to create a very simple PHP CLI application that can be run as a phar file from the command line: # php myProject.phar This is what I've tried so far: My Project My project is in a directory called MyProject and it has these two files in it: |-- createPhar.php `-- bootstrap.php bootstrap.php The bootstrap.php file contains this: <?php print phpversion() . PHP_EOL; print 'i am some script' . PHP_EOL; When I run this script from my Ubuntu command line: # cd MyProject # php bootstrap

PHP Phar - file_exists() issue

前提是你 提交于 2019-12-05 23:41:23
问题 My Phar script creates a new file with fwrite, which works fine, it creates the new file outside the phar, in the same directory as the phar file. But then when i use if(file_exists('file.php')) it doesn't pick it up. But then include and require do pick it up. Anyone know about this problem? Been testing and researching for a while a can't seem to find a solution. 回答1: At the PHAR's stub, you can use the __DIR__ magic constant to get the PHAR file's folder. With that in mind, you can simply

PHP: Class 'Phar' not found

只愿长相守 提交于 2019-12-05 09:18:11
问题 I try to use the Silex framework as base for my web application. However, if I try to include the *.phar archive, PHP throws the following error: Fatal error: Class 'Phar' not found in /var/www/framework/silex.phar on line 11 The following relevant lines are in my /etc/php/php.ini (as suggested in the docs of Silex): extension=phar.so phar.readonly = Off phar.require_hash = Off detect_unicode = Off The PHAR library is present in /usr/lib/php/modules/phar.so which is set as the extension path

Generating a PHAR for a simple application

为君一笑 提交于 2019-12-04 07:42:30
问题 I'm experimenting in building CLI tools using the Symfony2 console library. I've got something basic working and now I want to package it as a phar. I've read a few examples but the ones I've seen are very simple (3 files, no namespaces, etc). In my src/ directory I have the following: Above src/ I have a console.php that I execute to run the app. I also have a vendors/ dir as I'm using composer to install dependencies. console.php is very simple: #!/usr/bin/env php <?php set_time_limit(0);

PHP Phar - file_exists() issue

耗尽温柔 提交于 2019-12-04 05:13:55
My Phar script creates a new file with fwrite, which works fine, it creates the new file outside the phar, in the same directory as the phar file. But then when i use if(file_exists('file.php')) it doesn't pick it up. But then include and require do pick it up. Anyone know about this problem? Been testing and researching for a while a can't seem to find a solution. At the PHAR's stub, you can use the __DIR__ magic constant to get the PHAR file's folder. With that in mind, you can simply use is_file(__DIR__ . DIRECTORY_SEPARATOR . $path); To check for a file's existence outside the PHAR. You

How to run composer update on PHP server?

别等时光非礼了梦想. 提交于 2019-12-04 04:21:23
Is there a way to run composer update command on our production/test environment? Problem is that i don't have access for Command Line. WhipsterCZ Yes. there is a solution. but it could demands some server configuration... and some of these are forbidden by default due to security risks!! download composer.phar https://getcomposer.org/download/ - this is PHP Archive which can be extracted via Phar() and executed as regular library. create new php file and place it to web public folder. i.e. /public/composer.php or download at https://github.com/whipsterCZ/laravel-libraries/blob/master/public

Please explain how to create PHP's Phar stubs

安稳与你 提交于 2019-12-03 05:00:54
I'm trying to create a very simple PHP CLI application that can be run as a phar file from the command line: # php myProject.phar This is what I've tried so far: My Project My project is in a directory called MyProject and it has these two files in it: |-- createPhar.php `-- bootstrap.php bootstrap.php The bootstrap.php file contains this: <?php print phpversion() . PHP_EOL; print 'i am some script' . PHP_EOL; When I run this script from my Ubuntu command line: # cd MyProject # php bootstrap.php I get the following output: 5.3.2-1ubuntu4.9 i am some script createPhar.php The createPhar.php