Symfony 3.3 built-in server error - php

I'm developping an app under windows 10 + wamp + php 7 + Symfony 3.3
I'm trying to use the built-in server :
php bin/console server:run
[OK] Server listening on http://127.0.0.1:8000
// Quit the server with CONTROL-C.
And when I go to http://localhost:8000/app_dev.php/ or http://127.0.0.1:8000/app_dev.php
I get this error :
Warning: Unknown: failed to open stream: No such file or directory in Unknown on line 0
Fatal error: Unknown: Failed opening required 'C:\wamp\www\myproject\vendor\symfony\symfony\src\Symfony\Bundle\WebServerBundle/Resources/router.php' (include_path='.;C:\php\pear') in Unknown on line 0
Same error under every routes. My routes are correct and works fine outside of the built-in server...
Can you help me with this issue please ?

I had same problem,
Solved by :
Delete symfony folder in vendor
composer update
If you have antivirus (like Avast) disable it before launching web
server
php bin/console server:run

I got the same error, even when installing via composer.
It turns out that for whatever reason when composer downloaded the project, the required file listed in the error you get (vendor\symfony\symfony\src\Symfony\Bundle\WebServerBundle/Resources/router.php) was not included...
To fix this, I manually added it from https://github.com/symfony/web-server-bundle/blob/master/Resources/router.php and then my symfony app worked as expected.
I had to restart my computer in order to actually add the file because somehow I was locked out of adding it even as admin in Windows after launching the php server.
UPDATE:
Even better than manually adding the file, I just deleted the symfony folder from the vendor folder in the project and reran composer update. the router.php file is indeed downloaded. Sometimes when running bin/console server:run it gets deleted. Not sure why.

It happened to me when upgrading from Symfony 3.1 to Symfony 3.4.
The reason was that I had left the development server running when I executed the command:
composer update
The solution:
Delete the contents of vendor folder
Execute composer update
Install the new Symfony development server bundle (follow the instructions)
Execute the server for development in a new port
php bin/console server:start localhost:3421

I had this problem too : it was AVAST that blocked the "router.php" file.
I went into avast -> protection -> quarantine, and put an exception of the router.php file
And then everything worked again

I get the same error and I solve this issue by installing the project with composer
composer create-project symfony/framework-standard-edition my_project_name

Related

Failed to remove directory when using php cache:clear

When using composer install or cache:clear it will fail.
Failed to remove directory "/vagrant/download-server/var/cache/..8bS": rmdir(/vagrant/download-server/var/cache/..8bS): Text file busy
Previously when this error came up i could change from using a shared vm folder to direcly deploying
into the machine via phpstorm and this would fix it.
So i guess it has something to do with writing/reading speed.
Other than deploying directly into the vm. I also updated Vbox but this did not help.

Laravel installer throws error when creating new project

I am trying to create new Laravel application.
I have installed XAMPP and Composer.
With Composer ( composer global require laravel/installer ) I have installed Laravel.
But when I try to use laravel new firstProject command to create new command the instalation throws two errors.
I am using Windows 10 if that helps.
[RuntimeException]
The archive may contain identical file names with different capitalization (which fails on case insensitive filesys
tems): ZipArchive::extractTo(C:\Users\User1\Desktop\PHP/vendor/composer/374ddf59/laravel-laravel-8e55104\public/rob
ots.txt): Failed to open stream: Permission denied
[ErrorException]
ZipArchive::extractTo(C:\Users\User1\Desktop\PHP/vendor/composer/374ddf59/laravel-laravel-8e55104\public/robots.txt
): Failed to open stream: Permission denied
I have tried:
Reinstalling and updating composer
Reinstalling and updating Laravel
Changing folder where I want to create my project
Using the composer create-project laravel/laravel blog command to create new project through composer still the same errors as above
Read with understanding:
Failed to open stream: Permission denied.
This means that your command line have no access to read or write in current directory. You have to change directory permissions and it should work.
change permissions on windows
change permissions on mac
I had the same problem (Win10).
In my case, my antivirus (Avast) was denying access to composer, but I did not know because I had set Avast to silent mode, so it just denied permission without asking me.
Also, Avast quaranteened an important server.php file so artisan server would stop as soon as I tried loading a page. So I had to restore and allow that file too.
i have the solution.
You only need delete in c:\program file\7-Zip,
after you need, reinstall this software. 7-zip, You need download this software of webpage author.
after execute
laravel new your_app
and ready.

Unable to create Laravel project in PhpStorm

I am trying to create a new Laravel project in PhpStorm using the below steps.
Chosen option "Download composer from composer.org".
In the package list i have selected laravel/laravel with default version.
Create project.
After loading all the files it displays a short message in the bottom right corner of the IDE "Failed to run composer create-project" and I am unable to see that first page that comes when we run server.
I have also tried it using terminal by going into xampp/htdocs in VSCode and then running the below command
composer new laravel/installer
Changed current directory to /Users/abhishekabhishek/.composer
But it gives me the following error
The "https://repo.packagist.org/packages.json" file could not be downloaded: failed to open stream: Operation timed out
Retrying with degraded mode, check https://getcomposer.org/doc/articles/troubleshooting.md#degraded-mode for more info
I have no idea what is going on. Can anyone please help me resolve this issue. I am running this on Mac, there is nothing that I came across that can resolve this problem.
Step 1:
Download composer
Step 2:
Download the Laravel installer using Composer.
composer global require laravel/installer
Step 3:
laravel new blog
Step 4:
php artisan serve
This command will start a development server at http://localhost:8000
Tips:
After installing Laravel, you may need to configure some permissions. Directories within the storage and the bootstrap/cache directories should be writable by your web server or Laravel will not run.
sudo chmod 777 -Rf /folder/bootstrapdirectoryorcachedirectory
You dont need any VSCode or PHP Storm to do that.

Why am I getting this error message after I obtained my Laravel project from my GIT repository?

I am new in Laravel and I have the following problem.
I developed a Laravel 5 project on an old computer, and I put the code on a GIT repository. I retrieved my source code on my new laptop from the repository.
But I am facing problems while running the Laravel project on Apache and I am obtaining this error message on my Laravel website instead:
Warning: require(C:\xampp\htdocs\HotelRegistration\bootstrap/../vendor/autoload.php): failed to open stream: No such file or directory in C:\xampp\htdocs\HotelRegistration\bootstrap\autoload.php on line 17
Fatal error: require(): Failed opening required 'C:\xampp\htdocs\HotelRegistration\bootstrap/../vendor/autoload.php' (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\HotelRegistration\bootstrap\autoload.php on line 17
The C:\xampp\htdocs\HotelRegistration\bootstrap\autoload.php is present in my project
Why am I facing this issue? What is the problem? What am I missing? How can I fix this issue? How can I try to solve this issue?
You need to run
composer install
command to install packages. By default vendor directory is ignored when committing to GIT (this is good) so if you pull data from repository you need to install all packages running above command.

My Laravel installation error on localhost

I am new to Laravel, I have installed the Laravel on my localhost using
WAMP server but I am getting an error after all steps.
The errors are:
( ! ) Warning: require(C:\wamp\www\laravel/../bootstrap/autoload.php): failed to open stream: No such file or directory in C:\wamp\www\laravel\index.php on line 21
( ! ) Fatal error: require(): Failed opening required 'C:\wamp\www\laravel/../bootstrap/autoload.php' (include_path='.;C:\php\pear') in C:\wamp\www\laravel\index.php on line 21
I have used below link for Laravel installation
http://www.wikihow.com/Install-Laravel-Framework-in-Windows
I have tried to debug the issue but haven't found success in the installation.
Please let me know what is missing in installation.
You need to install Composer, open up the command prompt and cd to your directory (or hold Shift while right-clicking on your directory and clicking Open command window here) and there run composer install.
You can simplify the Laravel installation with Composers create-project command.
composer create-project laravel/laravel path
Laravel dependencies are not installed yet. That is why it is giving you this error.
https://getcomposer.org/download/
Go to this link and download composer if you haven't already.
Move the composer file to /usr/bin and rename it to just composer.
Go into the root directory of your laravel application. And run:
composer update
This will install and update all required dependencies.
In case you are on windows, which is less likely, but if you are, just download and install composer via the installer and issue the same command in you project's root directory.
Composer is PHP's dependency manager.
In the root directory of your laravel installation you will find a composer.json file. It contains the list of all your project's dependencies. If you ever need to install a package in your project, it becomes very easy. You just have to edit the composer.json file and let it know which package you need. Issuing composer update will install new package listings and update all existing ones.
just to be clear I'm not big fan of wamp.
I've just took quick look at the
http://www.wikihow.com/Install-Laravel-Framework-in-Windows
and I suppose laravel framework is not going to work best with point 11 to 14 modifications.
Baseline for laravel to work is you need to http serve /public folder in a properly configured environment (after composer install and create-project as described earlier).
If you want to take full advantage of laravel you need to often cli `php or composer (at least)` efficiently.
While using laravel I suggest installing PHP and MYSQL yourself from scratch (it really takes few minutes) and using convenient IDE (like PHPSTORM for example).
Nowadays PHP has builtin http server, so you don't need any http server in your dev environment.
So in Windows:
Install PHP and enable required libraries in php.ini
Install and configure local mysql server (easiest way installing via MySQL installer)
Start development server by invoking php.exe -S localhost:80 -t "absolute-path-to-your-laravel-installation\public" like for example C:\htdocs\laravel\public via commandLine
Enter url in your favorite browser http://localhost
Hope that will help to get you started.

Categories