Laravel installer throws error when creating new project - php

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.

Related

Error Symfony installation " The archive may contain identical file names with different capitalization"

I'm trying to create a new Symfony project.
When I launch the installer: symfony new sitepro --version=6.0.* --webapp
The installation start but then there is 2 errors:
[RuntimeException]
The archive may contain identical file names with different capitalization (which fails on case insensitive filesystems): ZipArchive::extractTo(C:\User
s\Shiyo\Desktop\Pro\Projets\sitepro/vendor/composer/b67ec329/php-fig-cache-aa5030c/LICENSE.txt): Failed to open stream: Permission denied
[ErrorException]
ZipArchive::extractTo(C:\Users\Shiyo\Desktop\Pro\Projets\sitepro/vendor/composer/b67ec329/php-fig-cache-aa5030c/LICENSE.txt): Failed to open stream: Pe
rmission denied
unable to run C:\composer\composer.phar create-project symfony/skeleton C:\Users\Shiyo\Desktop\Pro\Projets\sitepro 6.0.* --no-interaction
I'm working on Windows 10, php 8.1.6.
I tried composer clearcache, to uninstall and install 7-Zip and I have all the permissions for this folder so I really don't get why I have this error.
Thanks for your help!
The problem was the Desktop folder of Windows. It has special rights. I tried on an other folder and it work perfectly!

My folder is not opened in XAMPP localhost

Guys i am frustrated now, I just installed XAMPP yesterday. And I created a folder named "MyProgram" and there is one PHP file inside and basically its just a "Hello World" program. It works fine in the apache localhost.
And now when I created another new folder "MyAPI", I am trying to build another PHP thing with Vimeo API. But this time, no matter how many times I tried, I cant open my "MyAPI" folder on the localhost anymore. Usually when we open in the localhost, there will be a menu for us to choose what file to be opened, but im not sure why this is not working in this case. These are the error message:
Warning: require(vendor/autoload.php): failed to open stream: No such file or directory in D:\XAMPP\htdocs\MyAPI\index.php on line 9
Fatal error: require(): Failed opening required 'vendor/autoload.php' (include_path='D:\XAMPP\php\PEAR') in D:\XAMPP\htdocs\MyAPI\index.php on line 9
And FYI, this my folder:
And this is how I installed my composer:
You need to install your project dependencies first.
Open your terminal
Navigate to your project directory:
cd D:\XAMPP\htdocs\MyAPI\
Run composer install
try to run :
composer install
composer update --no-scripts
If you get the same error also when you run them
Just run this command first
composer dump-autoload
also make sure you run these commands inside the project folder

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.

Failure to find autoload.php

I'm stuck on a very basic problem:
I'm trying to use Laravel, which I installed on my windows 7 with composer.
When I try to access my website locally with Wamp, I get the error:
Warning:
require(C:\wamp\www\sitedirectory\public\protected\bootstrap/../vendor/autoload.php):
failed to open stream: No such file or directory in
C:\wamp\www\sitedirectory\public\protected\bootstrap\autoload.php on
line 17
Everywhere I can read that all I have to do is run composer install or update.
The problem is that I did run both and nothing has to be updated.
The files are where they are needed so I dont understand what could be the problem.
Does anyone have an idea of what could be my problem?
Thank you in advance.
Composer is a tool for managing and installing dependencies.
There should exist a file named composer.phar in the directory C:\wamp\www\sitedirectory\public\protected\. There you should execute the command composer.phar install (on the command line).
Then, the directory vendor containing the autoload.php etc. should be generated.
If the composer.phar does not exist (but at least a file named composer.json), follow the steps explained here to download composer.

Warning: require(...): failed to open stream: No such file or directory in

just moved over my laravel site to my live server and straight away faced with this error.
The complete error is:
Warning: require(/var/sites/b/beta.buildsanctuary.com/public_html/local/bootstrap/../vendor/autoload.php): failed to open stream: No such file or directory in /var/sites/b/beta.buildsanctuary.com/public_html/local/bootstrap/autoload.php on line 17
Fatal error: require(): Failed opening required '/var/sites/b/beta.buildsanctuary.com/public_html/local/bootstrap/../vendor/autoload.php' (include_path='.:/usr/local/lib/php') in /var/sites/b/beta.buildsanctuary.com/public_html/local/bootstrap/autoload.php on line 17
The line 17 is:
require DIR.'/../vendor/autoload.php';
Folder structure is:
beta.buildsanctuary.com
-- public_html
-- subdomains
-- beta
-- local
-- bootstrap
-- vendor
Any help where this is going wrong? And how to fix? Pulling my hair out trying all sorts of paths.
Thanks, Craig.
I strongly believe that a corrupted cache was the cause, I cannot be 100% sure but it seem that it is likely the culprit.
So, if anyone comes across a similar problem, I would suggest the following steps:
Delete the vendor folder
Delete composer.lock
Run the command composer clearcache (or clear-cache)
Run composer install
I hope this can help somebody.
As you can see from the error, PHP is looking for
public_html/local/bootstrap/../vendor/autoload.php`
which is
public_html/local/vendor/autoload.php
That folder does not exist. I think the folder structure you posted is wrong.
Anyway, try this:
require('../vendor/autoload.php');
I've had the same problem and it was that Composer was not installed yet in the server, so the directories structure it creates on your project does not exist neither.
First you have to install composer on your server, follow the instructions for your system given at the composer project webpage, https://getcomposer.org/.
Next you have to go in a terminal or cmd to the base folder of your project.
There you can use the commandline composer init, wich will guide you to create your composer.json file into your project.
Once you have created your composer.json file, you have to execute the commandline composer install.
This commandline will create all the dependencies you have written on your composer.json, and also will create the folder structure so the code you require would find the proper path.
At last, you have to reference the redirection to the folder vendor depending on the current folder structure location of your php file.
If you look for information, http://www.phptherightway.com/ was really helpfull.
Just run the following command, it will automatically install necessary dependencies:
composer install
I had the same problem when I have had migrated a drupal website to new server...
To solve the problem I just used the composer command:
First cd into website directory, EX:
cd /var/www/your_website
Run composer to install drupal 8 dependencies that it's need in the website directory;
composer install
If you use the sudo command, make sure the .../vendor directory has the right permission to be accessed by the user who in the /var/wwwdirectory;
sudo composer install
This basically will solve the .../public_html/autoload.php on line 14 issue!

Categories