Symfony 4 - php bin/console server:run not works - symfony

I have a problem with this command : php bin/console server:run on Symfony 4
When I go to http://127.0.0.1:8000/ I have this error message :
Warning: Unknown: failed to open stream: No such file or directory in Unknown on line 0
Fatal error: Unknown: Failed opening required 'J:\my_project\vendor\symfony\web-server-bundle/Resources/router.php' (include_path='.;C:\php\pear') in Unknown on line 0
Indeed, the router.php file does not exist !
But if I run this command : php -S 127.0.0.1:8000 -t public everything is ok.
Any idea ?

First check that you have installed the SF4 Web Server bundle :
> composer require server --dev
then you can start using it through Symfony using run / start command

Not sure if this is the case for you too, but it is probably worth checking (and may also be interesting for others having the same problem).
My antivirus software likes to put the router.php in quarantine (effectively removing it from that directory). Check if yours did the same and if so restore it and create an exception for that file. Additionally you should configure your antivirus to notify you if it puts something in quarantine, so you can intervene in time.

Related

error when I try to open app_dev.php file

I install symfony 2 under htdocs(xampp) folder, I start apache then I try to open app_dev.php file using this url :
http://localhost/symfony2/web/app_dev.php
I get this error :
Warning: require(C:\xampp\htdocs\symfony2\app/../vendor/autoload.php):
failed to open stream: No such file or directory in
C:\xampp\htdocs\symfony2\app\autoload.php on line 9
Fatal error: require(): Failed opening required
'C:\xampp\htdocs\symfony2\app/../vendor/autoload.php'
(include_path='C:\xampp\php\PEAR') in
C:\xampp\htdocs\symfony2\app\autoload.php on line 9
the tutorial that I follow (here) say that it will open a page
I reistall symfony using this command :
$ composer create-project symfony/framework-standard-edition my_project_name "2.7.*"
it works perfectly
Best way is to start symfony via the console to get the development enviroment:
bin/console server:run
http://symfony.com/doc/current/book/installation.html#running-the-symfony-application
Also check the read and write privileges, and check the composer installation.

Symfony2 Bootstrap.php.cache

I'm developing in Ubuntu 14 and I get the following error when creating a databaes:
$ php app/console doctrine:database:create
This is the error output:
PHP Warning: require_once(/home/jesse/playground/www/symfony/htdocs/app/bootstrap.php.cache):
failed to open stream: No such file or directory in
/home/jesse/playground/www/symfony/htdocs/app/console on line 10
PHP Fatal error: require_once(): Failed opening required
'/home/jesse/playground/www/symfony/htdocs/app/bootstrap.php.cache'
(include_path='.:/usr/share/php:/usr/share/pear') in
/home/jesse/playground/www/symfony/htdocs/app/console on line 10
What Ive Tried
Running this in Vagrant
Running this Locally
This is one among several problem running Symfony2 under Ubuntu, the other forcing you to implement umask(0000) otherwise you have to get chmod +a permissions for log and cache folders, this seems like a bit of a hassle for something seemingly simple.
Does anyone know what to work around this error?
This should do the trick:
php /home/jesse/playground/www/symfony/htdocs/vendor/sensio/distribution-bundle/Sensio/Bundle/DistributionBundle/Resources/bin/build_bootstrap.php

Prod logs in symfony 2 not using root dir

I'm developping a symfony2 website. I'm using apache2.2.
Everything works fine in dev environment.
But when i want to try it on the prod environment, it goes :
Fatal error: Uncaught exception 'UnexpectedValueException' with message 'The stream or
file "/var/www/domain/app/logs/prod.log" could not be opened:
fopen(/var/www/domain/app/logs/prod.log) [function.fopen]: failed to open stream: No
such file or directory' in /var/www/myapp/app/cache/prod/classes.php on line 4799
Why is it trying to write in /var/www/domain since my application is in /var/www/myapp ?
I tried to modify the config_prod.yml to no result.
Any idea ?
Thanks
#Boris Guéry it was a cache problem, you were right, but i couldn't use de command line to clear it. I had to use rm -rf in the shell.
Thanks

stange error with Behat and Mink on Sf2

I'm using Behat,mink in my Symfony2 project,so I follow those tutorials to make installation :
http://extensions.behat.org/symfony2/ , http://extensions.behat.org/symfony2/migrating_from_2.3_to_2.4.html
but when I run this command php behat.phar --init "#YouBundleName",I get this very strange error :
PHP Warning: require(Behat\MinkExtension\Extension): failed to open stream: No such file or directory in phar:///var/www/project/behat.phar/src/Behat/Behat /Extension/ExtensionManager.php on line 112
PHP Fatal error: require(): Failed opening required 'Behat\MinkExtension\Extension' (include_path='.:/usr/share/php:/usr/share/pear') in phar:///var/www/project/behat.phar/src/Behat/Behat/Extension/ExtensionManager.php on line 112
I'm sure I installed the last version of behat and mink mentionned in the second link above and then I made php composer.phar unpdate and cache clear too,but still the same error?
I had the same problem. Forgot you need to install behat/mink-extension as well as behat/mink. For example you might need to run:
php composer.phar require behat/mink-extension:*
Worked for me.
By the way, looks like you got confused by the two installation methods, phar vs composer. I'd go with the composer route because it's easier to update and manage versions. This would mean running php bin/behat ... instead of php behat.phar ....

symfony2 load fixtures gives error, please advise on how to fix?

i am on part Updating the blog entity where i need to load the fixtures with command:
$ php app/console doctrine:fixtures:load
but i get an error:
php app/console doctrine:fixtures:load
> purging database
> loading Blogger\BlogBundle\DataFixtures\ORM\BlogFixtures
> loading Blogger\BlogBundle\DataFixtures\ORM\CommentFixtures
[ErrorException]
Warning: file_put_contents(/home/helloises/symfony2/Symfony/app/cache/dev/doctrine/orm/Proxies/Blogge rBlogBundleEntityBlogProxy.php): failed to open stream: Permission denied in
/home/helloises/symfony2/Symfony/vendor/doctrine/lib/Doctrine/ORM/Proxy/ProxyFactory.php
line 155
please help?
thanks
This is a permission error:
You don't have the write permission in the app/cache/dev/doctrine/orm/Proxies directory of your project so doctrine fails to create its proxy classes.
Maybe you gave the write permission to your HTTP server user (so the web works) but not to the user you used to execute the command.
See the Setting up Permissions paragraph in http://symfony.com/doc/current/book/installation.html#configuration-and-setup

Resources