I'm trying to execute ZendSkeletonApplication example for frist time.
I've acted pursuant this articles from official Zend site:
http://framework.zend.com/manual/2.0/en/user-guide/skeleton-application.html
BUT
Why should I download again all dependecies (entire ZF2) via composer if I already downloaded it (ZF2) from Git as zip archive?
Or Does part with php composer doing anything else than downloading entire ZF2? (I've very slow connection so it's problem)
I still get this error:
Fatal error: Uncaught exception 'RuntimeException' with message
'Unable to load ZF2. Run php composer.phar install or define
a ZF2_PATH environment variable.'
My approach is following: (Using Win7, PHP 5.3.5)
I downloaded entire ZF2 and ZendSkeletonApplication from Git as zip archives.
I Unziped ZF2 to htdocs/ directory. (Now my path to the framework is: xampp/htdocs/ZendFramework-2.3.1/ )
I Unziped ZendSkeletonApplication to htdocs/ (Path location: xampp/htdocs/zf2-tutorial/ )
I checked presence of openssl extension. It's now enabled in php.ini
I added the Zend Framework’s library path to the PHP include_path in php.ini
( include_path = ".;C:\xampp\php\PEAR; C:\xampp\htdocs\ZendFramework-2.3.1\library" )
Now, If I type: localhost/zf2-tutorial/public/ , I get FatalError as I mentioned above..
Need I setup some other settings in ZendSkeletonApplication?
Is it possible to install dependencies via php composer from downloaded zip archive of ZF2? (No internet connection) ... If so, How can I setup the composer?
EDIT:
After XAMPP update (php 5.5) I was capable to successfuly access ZFSkeletonAppllication's introductory site (localhost/) after I set ZF2_PATH environment variable.
Ok, but unfortunately same FatalError still occur right when I got to the next chapter of ZF2 SkeletonApplication:
http://framework.zend.com/manual/2.0/en/user-guide/unit-testing.html
There, PHPUnit framework has been involved to ZF2 application.
When I want to run phpunit I get same error as above:
Fatal error: Uncaught exception 'RuntimeException' with message
'Unable to load ZF2. ....
I setuped ZF2_PATH environment variable in httpd.conf to:
SetEnv ZF2_PATH c:/xampp/htdocs/ZendFramework-2.3.1/library
I really don't know what I can do now...
Thanks for help.
Chances are include_path not working. You need to debug it why. Otherwise you can set ZF2_PATH environment variable as error itself demanded. It is easy way as you may setup framework at one folder while just need to setup ZF2_PATH variable. For debug, how ZF2 autoloading works, check /init_autloader.php .
No need to using composer every time for project setup. I also found it very annoying in composer way to install every time ZF2.
Related
When I try to run my project in localhost I am getting the above error.
The thing is I already installed the composer. In terminal I get the confirmation saying
Composer (version 1.4.2) successfully installed to: /home/martin/composer.phar
Use it; php composer.phar
Even I tried the command composer It is showing the Composer things.
What should I do to get rid of the error Fatal error : Uncaught Runtime Exception ....
For this issue you need to change php files.
1.php.ini
You can add the Zend Framework’s library path to the PHP include_path.
You can find include_path in php.ini.
Example #1 Unix include_path
include_path=".:/php/includes"<br>
Example #2 Windows include_path
include_path=".;c:\php\includes"
2.httpd.conf
You should set an environment path named ‘ZF2_PATH’ in httpd.conf (or equivalent). i.e. SetEnv ZF2_PATH /var/ZF2 running Linux.
I am trying to install Symfony on CentOS Linux wih PHP 5.6 and cPanel installed.
When I run composer require symfony/assetic-bundle , once adding bundle to the AppKernelphp, symfony (app/console too) stops working and keeps logging this error:
[10-Jun-2016 22:00:57 UTC] PHP Fatal error: Class 'Symfony\Bundle\AsseticBundle\AsseticBundle' not found in /home/avid24/public_html/app/AppKernel.php on line 19
After checking the vendor directory, turns out that composer has downloaded a single compressed file with a random name, I could extract it with unzip. but problem still exists!
This environment works properly on windows and I could easily update symfony and its components using composer.
Any help? Anyone with the same experience ?
Well, I eventually figured out the problem!
I enabled suhosin extension which prevents the composer and other similar command prompt php scripts from a proper execution.
As a temporary solution I copied php.ini and disabled unnecessary extensions and put it next to my project and call composer this way
$php -c ../composer-php.ini ~/composer ......
I'll create a script to make the life easier
I didn't find any resource which describes coexistence of composer and suhosin extension, so I'm not sure if this is the ultimate solution but the root cause is identified.
If anybody makes workaround this subject I'd be more than happy to know about it.
I have some test under features directory. But when I try to run behat I get the following error:
$ ls
behat.yml features
$ behat
PHP Warning: Module 'memcache' already loaded in Unknown on line 0
PHP Warning: require_once(PHPUnit/Autoload.php): failed to open stream: No such file or directory in $HOME/workspace/ums/api/trunk/tests/functional/features/bootstrap/FeatureContext.php on line 24
PHP Fatal error: require_once(): Failed opening required 'PHPUnit/Autoload.php' (include_path='.:/usr/share/pear:/usr/share/php') in $HOME/workspace/ums/api/trunk/tests/functional/features/bootstrap/FeatureContext.php on line 24
Since PHPUnit is no longer available to install using PEAR, I finally use Composer. So have my PHPUnit libraries installed under
$ sudo find / -name PHPUnit
/HOME/.composer/vendor/phpunit/phpunit/PHPUnit
/HOME/.composer/vendor/phpunit/phpunit-mock-objects/PHPUnit
/tmp/ZendFramework-1.11.0/library/Zend/Test/PHPUnit
/tmp/ZendFramework-1.11.0/tests/Zend/Test/PHPUnit
/usr/share/php/Zend/Test/PHPUnit
/usr/share/php/Zend-2.0/Test/PHPUnit
Which is the best way to set include_path without changing php.ini file and not use set_include_path() method in each FeatureContext.php example type class ?
Any help would be appreciated!
I ran into the same error using phpunit along with Behat, I did manage to overcome it with the following code:
require_once __DIR__.'/../../vendor/autoload.php';
require_once __DIR__.'/../../vendor/phpunit/phpunit/src/Framework/Assert/Functions.php';
Given that the 'bootstrap' folder is only one two folders away from the root of the project. Hopes it helps.
Usually I have PHPUnit installed globally (via composer) on my dev and test (CI server) machines so I wont run into any trouble when running the tests. Also, in order to have the auto completion properly working of my favorite IDE (PhpStorm) I include the library in the composer.json of the project as a dev requirement. In the case of a project that uses Behat and is developed by a team the best way is to include it in the project so no developer would run into trouble when running the test.
You want to use the autoloader that comes with composer. Try adding
require_once 'path/to/vendor/autoload.php'
before using PHPUnit
I have a problem with Symfony assets on heroku (official php buildpack).
My code is based on Symfony 2.5 with new 3.0 folder structure, and it's using one local js and css file (the rest is loaded via cdn).
Those files are loaded exactly as described here: http://symfony.com/doc/current/cookbook/assetic/asset_management.html.
On dev environment everything is ok, but when i change env to prod then i need to do assetic:dump to force symfony dump my assets files into web/css|js folders. I made test on my local machine (switching env to prod) and everything is ok. The problem is with heroku, and its ephemeral filesystem:
When I try to run assetic:dump --env=prod by composer post-install-cmd, then deploy finish with successs, but every request ends up with:
AH01071: Got error 'PHP message: PHP Fatal error: Uncaught exception
'InvalidArgumentException' with message
'The file "/tmp/build_012d99e7-a14a-4626-afec-3ded3d4baeec/app/config/routing.yml"
When i deploy app without assetic:dump then of course my local css and js files are not available :/
Maybe there is some other script hook i can use to dump my assets?
Any ideas? Anyone succeded with assetic:dump on heroku and official php buildpack?
PHP and Symfony support has been revamped a lot in the last months, check out these links:
http://symfony.com/doc/current/cookbook/deployment/heroku.html
https://devcenter.heroku.com/articles/getting-started-with-php
https://devcenter.heroku.com/articles/php-support
https://devcenter.heroku.com/articles/getting-started-with-symfony2
What's most important:
Set an environment variable for SYMFONY_ENV
The value of SYMFONY_ENV is used to define the environment for CLI commands. So you don't have to fiddle about something like --env=prod in you custom commands. Composer hooks from composer.json (like post-install-cmd) are automatically executed with the defined environment. Please note: Set it to something different than dev. A dev environment may not work well on Heroku because Composer's dev dependencies (require-dev) are not installed. This is due to the --no-dev flag during the composer install on Heroku. For example, in the Symfony Standard Edition) the SensioGeneratorBundle never gets installed (if you do not move it to the require key in composer.json) and the dev environment won't work.
Error on /tmp path
The mentioned error should have been fixed with https://github.com/symfony/symfony/pull/12784. See also https://github.com/heroku/heroku-buildpack-php/issues/64.
Custom commands during deployment
Custom commands like assetic:dump can be placed in composer.json's script section under the compile key:
{
"scripts": {
"compile": [
"app/console assetic:dump"
]
}
}
See also https://devcenter.heroku.com/articles/php-support#custom-compile-step. Environment is taken from the above mentioned SYMFONY_ENV environment variable.
I am running phpStorm 7.1.3 version on Windows 7 and I have done everything accordingly to install composer and then phpunit. Now I have it in vendors directory. But every time I run my program which is a simple Yii application I get the same error.
PHP Fatal error: Uncaught exception 'UnexpectedValueException' with
message 'Cannot create phar
'C:/wamp/www/myproject/vendor/bin/phpunit', file extension (or
combination) not recognised or the directory does not exist' in
C:\Users\myUser\AppData\Local\Temp\ide-phpunit.php:177
Please help, I am stuck here already two days and cant get this working, almost changed and reinstalled everything but is not helping.
I didn't use pear, I downloaded everything through the phpStorm. I downloaded composer, and after that through phpStorm composer I downloaded phpUnit 3.7.37.
Here is the screenshot of my settings for composer
Here is the content of my composer.json
{
"require": {
"phpunit/phpunit": "3.7.37"
}
}
Here is the screenshot of my settings for PHPunit
On your 2nd screenshot (PHPUnit settings):
Why did you choose PHAR option if you are using COMPOSER?
Why did you point to .../bin/phpunit (even if you choose 3rd option .. you should point it to a PHAR file then)?
Therefore:
For composer installations you should use 2nd ("Use custom loader") option.
The edit box -- you should point it to your autoloader script (yes -- composer autoloader script).
Related (similar issue): https://stackoverflow.com/a/17316104/783119
If you are not using composer, but the 'Path to phpunit.phar' option and still receive this error, just make sure the path you specify ends with a .phar (usually ends with phpunit.phar) I was seeing this same error but because I had the path pointing to my command-line alias, not the actual .phar file, it gets hung up on the improper extension and bails.
I was trying to run phpUnit on zend framework 1.12.9 and had the same problem - solved it by changing path to phpunit.phar to use custom loader.
Then You have to point it to the generated autoload.php by composer.
In my case that was
C:\wamp\www\phpu3\vendor\autoload.php
Later, the important thing to do was to point the bootstrap file from tests.
When you download the phpunit.phar file using the wget command, following the instruction on the getting started manual -
https://phpunit.de/getting-started/phpunit-4.html
the "phar" extension is being removed, and PHPSTORM has issues to interrupt this file. I've changed the extension:
mv phpunit phpunit.phar
make sure you update the path to phpunit.phar file in the IDE setting accordingly