How to configure a composer package to be globally installed? - php

I'm trying to make a little CLI tool and package it up with composer.
Below is an extremely simplified version of the program, but it's enough to demonstrate the problem I'm encountering.
The project has one dependency, and one "binary" file
composer.json
{
"name": "alice/yamldump",
"version": "0.2.0",
"bin": [
"bin/yamldump"
],
"require": {
"symfony/yaml": "2.5.3"
}
}
bin/yamldump
#!/usr/bin/env php
<?php
// use Yaml namespace
use Symfony\Component\Yaml as Yaml;
// autoload
require_once "vendor/autoload.php";
// read yaml
$yaml = file_get_contents(sprintf("%s/%s", getcwd(), $argv[1]));
// create parser
$parser = new Yaml\Parser();
// parse the yaml
var_dump($parser->parse($yaml));
So when I install it globally, I get this
$ composer global require alice/yamldump=dev-master
Files are installed to
~/.composer/vendor/bin/yamldump -> ../alice/yamldump/bin/yamldump
~/.composer/vendor/alice/yamldump/
~/.composer/vendor/symfony/yaml/
This is a problem, because I did not intend to globally install symfony/yaml and my package's vendor/autoload.php can no longer find the Yaml package in the proper location.
I don't mind that symfony/yaml was installed globally, but it would make sense to me that composer global require would install the package like this:
~/.composer/vendor/bin/yamldump -> ../alice/yamldump/bin/yamldump
~/.composer/vendor/alice/yamldump/
~/.composer/vendor/alice/yamldump/vendor/symfony/yaml/
After all, what if I have Package A that depends on symfony/yaml=2.5.3 and Package B that requires symfony/yaml=2.6.x?
If the composer global require installs dependencies to ~/.composer/vendor/*, each globally required package can't maintain it's own version requirement of its dependency...
I know this is sort of a convoluted problem, but I really don't know how to begin fixing it.
The goal
A user should be able to
$ composer global require alice/yamldump=dev-master
$ yamldump sample.yml
The error
$ yamldump sample.yml
Warning: require_once(vendor/autoload.php): failed to open stream: No such file or directory in /Users/alice/.composer/vendor/alice/yamldump/bin/yamldump on line 8
Fatal error: require_once(): Failed opening required 'vendor/autoload.php' (include_path='.:') in /Users/alice/.composer/vendor/alice/yamldump/bin/yamldump on line 8
The question
Here it is in black & white:
How am I intended to write the require "vendor/autoload.php" line and have it work for both locally installed packages and globally installed packages?

Targeting vendor/autoload.php is generally not a good idea and only works if you run the script from the correct directory. The following should serve you better:
require_once __DIR__.'/../vendor/autoload.php';
However, this still might be an issue if your application is installed as a dependency. In that case, you might need something more substantial:
if (
(!$classLoader = includeIfExists(__DIR__.'/../vendor/autoload.php')) &&
(!$classLoader = includeIfExists(__DIR__.'/../../../autoload.php'))
) {
echo 'You must set up the project dependencies, run the following commands:'.PHP_EOL.
'curl -sS https://getcomposer.org/installer | php'.PHP_EOL.
'php composer.phar install'.PHP_EOL;
exit(1);
}
This first looks for the autoloader in the location you would expect it to be if you are working directly on your application. If that does not exist, it looks where the autoloader would be if your application is installed as a dependency.

Related

Email verification on registration using php Mailer not working [duplicate]

I know that this issue has been posted many times, but for me it seems to be a different problem.
Indeed, this error
Warning: require(vendor/autoload.php): failed to open stream: No such file or directory in C:\xampp\htdocs\site_web\send_mail.php on line 3
Fatal error: require(): Failed opening required 'vendor/autoload.php' (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\site_web\send_mail.php on line 3
appears at the begining of my code from this line:
require 'vendor/autoload.php';
So, I guess there must be a /vendor/autoload.php file somewhere in my computer (I have installed composer and ran composer require phpmailer/phpmailer).
So, I looked for this file using: dir /s autoload.php in the Windows command line, and found one here: C:\Windows\SysWOW64\vendor\autoload.php,
but for me, syswow64 folder has nothing to see with autoload.php, I don't see what I am missing here.
What you're missing is running composer install, which will import your packages and create the vendor folder, along with the autoload script.
Make sure your relative path is correct. For example the example scripts in PHPMailer are in examples/, below the project root, so the correct relative path to load the composer autoloader from there would be ../vendor/autoload.php.
The autoload.php you found in C:\Windows\SysWOW64\vendor\autoload.php is probably a global composer installation – where you'll usually put things like phpcs, phpunit, phpmd etc.
composer update is not the same thing, and probably not what you want to use. If your code is tested with your current package versions then running update may cause breakages which may require further work and testing, so don't run update unless you have a specific reason to and understand exactly what it means. To clarify further – you should probably only ever run composer update locally, never on your server as it is reasonably likely to break apps in production.
I often see complaints that people can't use composer because they can't run it on their server (e.g. because it's shared and they have no shell access). In that case, you can still use composer: run it locally (an environment that has no such restrictions), and upload the local vendor folder it generates along with all your other PHP scripts.
Running composer update also performs a composer install, and if you do not currently have a vendor folder (normal if you have a fresh checkout of a project), then it will create one, and also overwrite any composer.lock file you already have, updating package versions tagged in it, and this is what is potentially dangerous.
Similarly, if you do not currently have a composer.lock file (e.g. if it was not committed to the project), then composer install also effectively performs a composer update. It's thus vital to understand the difference between the two as they are definitely not interchangeable.
It is also possible to update a single package by naming it, for example:
composer update ramsey/uuid
This will re-resolve the version specified in your composer.json and install it in your vendor folder, and update your composer.lock file to match. This is far less likely to cause problems than a general composer update if you just need a specific update to one package.
It is normal for libraries to not include a composer.lock file of their own; it's up to apps to fix versions, not the libraries they use. As a result, library developers are expected to maintain compatibility with a wider range of host environments than app developers need to. For example, a library might be compatible with Laravel 5, 6, 7, and 8, but an app using it might require Laravel 8 for other reasons.
Composer 2.0 removed any remaining inconsistencies between install and update results; if you're running composer 1.x you should definitely upgrade.
If you get the error also when you run
composer install
Just run this command first
composer dump-autoload
This command will clean up all compiled files and their paths.
#Bashir almost helped me but I needed:
composer update --no-scripts
Apparently this prevents any scripts from being included before executing artisan.
I found the answer here half-way down the page:
https://laracasts.com/discuss/channels/general-discussion/fatal-error-class-illuminatefoundationapplication-not-found-in-pathtoprojectbootstrapappphp-on-line-14?page=0
Proper autoload.php configuration:
A) Quick answer:
Your autoload.php path is wrong. ie. C:\Windows\SysWOW64\vendor\autoload.php
To date: you need to change it to: C:\Users\<Windows User Name>\vendor\autoload.php
B) Steps with example:
We will take facebook/php-graph-sdk as an example; change to Package Name as needed.
Install composer.exe
Open CMD Prompt. + R + type CMD
Run This command: composer require facebook/graph-sdk
Include path in your PHP page: require_once 'C:\Users\<Windows User Name>\vendor\autoload.php';
Define configuration Secrets and Access Token for your package...etc.
Happy codinig.
C) Further details:
Installing composer on windows will set this default path for your pacakges; you can find them there and include the autoloader path:
C:\Users\<Windows User Name>\vendor
For the same question you asked; the answer was this path for WAMP Server 64 BIT for Windows.
Then simply in your PHP Application change this:
require_once __DIR__ . '/vendor/autoload.php';
To:
require_once 'C:\Users\<Windows User Name>\vendor\autoload.php';
Find your windows username under C:\Users\
Before all this, as pointed before in B) , you need to run this command:
composer require <package name>
for facebook php SDK for example:
composer require facebook/graph-sdk
Thank you for asking this question; appreciated as it helped me fix similar issue and ended writing this simple tutorial.
First make sure you have installed the composer.
composer install
If you already have installed then update the composer.
composer update
If you have cloned your project from Github or got it from somewhere else, you will encounter this error. That's because you are missing the vendor folder and other files. The vendor folder contains packages which are dependent to your project. The package dependencies are stored in composer.json file and the folder was excluded while pushing to Github.
Fix this error by simply running:
composer install
Then you will get all the assets needed for your project.
First, review route inside index.php
require __DIR__.'/../vendor/autoload.php';
$app = require_once __DIR__.'/../bootstrap/app.php';
in my case the route did not work, I had to review the directories.
For me
Just run this command first
composer dump-autoload
to add vendor folder.
then run this command
composer update --no-scripts
to update composer.
Create composer.json file with requisite library for ex:
{
"require": {
"mpdf/mpdf": "^6.1"
}
}
Execute the below command where composer.json exists:
composer install
In case of Drupal :
Use the web root folder of drupal to include autoload for ex:
define('DRUPAL_ROOT', getcwd());
require_once DRUPAL_ROOT . '/vendor/autoload.php';
In case of other systems:
Use the root folder variable or location to include the autoload.php
I had this path in my machine:
C:/xampp5.0/htdocs/project-recordando-symfony/project-recordando-symfony
Then I ran composer install or/and composer update and it returned this error:
ErrorException ZipArchive::extractTo...
That error is because your path is too much long, I changed to:
C:/xampp5.0/htdocs/p-symfony/*
and worked!
run composer update. That's it
I was able to resolve by removing composer and reinstalling the proper way. Here is what I did:
sudo apt remove composer
sudo apt autoclean && sudo apt autoremove
Installed globally with the instructions from: https://getcomposer.org/doc/00-intro.md
Download from: https://getcomposer.org/installer
global install: mv composer.phar /usr/local/bin/composer
(Note: I had to move mine to mv composer.phar /usr/bin/composer)
I was then able to get composer install to work again. Found my answer at the bottom of this issue: https://github.com/composer/composer/issues/5510
In your project folder, the vendor folder is missing so you got this error:
Warning: require(vendor/autoload.php): failed to open stream: No such file or directory in
When you download the project through git, the project is downloaded without the vendor folder
You need /vendor because all your packages are there, including all the classes Laravel uses. The vendor directory contains your Composer dependencies.
The solution is simple, Just run this command:
composer update --no-scripts
composer update
composer update --no-scripts It will Skips execution of scripts defined in composer.json file.
composer update It will update your depencencies as they are specified in composer.json file.
With this command, you will re-create the vendor folder in your project and after that your project will start working normally.
This error occurs because of missing some files and the main reason is "Composer"
First Run these commands in CMD
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === 'e0012edf3e80b6978849f5eff0d4b4e4c79ff1609dd1e613307e16318854d24ae64f26d17af3ef0bf7cfb710ca74755a') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
Then
Create a New project
Example:
D:/Laravel_Projects/New_Project
laravel new New_Project
After that start the server using
php artisan serve
In my case, It was due to the non-fully installation of the project, because I didn't have enough space on my hard disk
There will be a directory called "vendor" that needs to be in your root directory if you have a cloned repository and trying to set up that time this type of error occurring.
".gitingore" file has written code to not include vendor directory on GIT so after cloning GIT your project facing the issue of missing vendor directory.
Once you add vendor directory your project will start working again.
Change the auto_prepend_file property on php.ini
; Automatically add files before PHP document.
;http://php.net/auto-prepend-file
auto_prepend_file =
In linux first add github Personal access tokens
Navigate to GitHub's Personal Access Tokens page.
Hit "Generate new token" button.
Type something meaningful "Note", select "repo" as scope and hit "Generate token" button.
Take a note of the token.
5 type in terminal with you new "personal access token"
export COMPOSER_AUTH='{"github-oauth":{"github.com":"AB8cd4cab23a9d5399934a7d7698d3fa74e9cfAB"}}'
Run in terminal composer install

Composer not generating doctrine-migrations PHP file into vendor/bin directory

I have inherited an old legacy system based off Yii 1.1 which has had multiple development teams working on it for the past 10 years so is a bit of a mess with little to no documentation.
Doctrine Migrations have been used in the past and I can get this working on Docker, however on the live EB/EC2 instance, the migrations files will not run from command line.
Command:
php vendor/bin/doctrine-migrations status
Throws error
PHP Warning: require(/var/app/current/site/vendor/bin/doctrine-migrations.php): failed to open stream: No such file or directory in /var/app/current/site/vendor/bin/doctrine-migrations on line 8
PHP Fatal error: require(): Failed opening required '/var/app/current/site/vendor/bin/doctrine-migrations.php' (include_path='.:/usr/share/pear7:/usr/share/php7') in /var/app/current/site/vendor/bin/doctrine-migrations on line 8
Looking at my local environment versus the live server, no doctrine-migrations.php file has been created in vendor/bin on the dev server, which composer should have created and is the file being looked for. Composer install is run during build on every deployment but I can't figure out why it is not auto-generating this file in the vendor/bin directory - just another file called doctrine-migrations which pretty much just requires doctrine-migrations.php:
#!/usr/bin/env php
<?php
declare(strict_types=1);
namespace Doctrine\Migrations;
require __DIR__ . '/doctrine-migrations.php';
conposer install install bundle declared in your composer.lock file.
Your composer.lock file is generated when doing your first composer install or a composer update or composer require
Difference may occur between your local environment and production environment.
Indeed, on local, composer install install some bundle only needed in dev mode (see your require-dev part in composer.json)
Either the composer.lock file is not up to date with your composer.json file (if composer.json contain the required bundle) either the required bundle is set as require-dev
To install it, you can run composer install doctrine/doctrine-migrations-bundle

Fatal error: Interface 'Coinbase\Wallet\Authentication\Authentication' not found

I am trying to coinbase PHP API, I have downloaded PHP library from GitHub and created an index.php file to start working, below is index codes
<?php
require_once('src/Client.php');
require_once('src/Configuration.php');
require_once('src/Authentication/ApiKeyAuthentication.php');
use Coinbase\Wallet\Client;
use Coinbase\Wallet\Configuration;
$apiKey="";
$apiSecret="";
$configuration = Configuration::apiKey($apiKey, $apiSecret);
$client = Client::create($configuration);
?>
And this is generating below error
Fatal error: Interface 'Coinbase\Wallet\Authentication\Authentication' not found in /home/exhakduz/api/coinbase-php-master/src/Authentication/ApiKeyAuthentication.php on line 8
I can't find any solution
Use composer instead, and require the composer autoloader within your index.php. The docs suggest to install the library with composer as well.
Install the library using Composer. Please read the Composer
Documentation if you are unfamiliar with Composer or dependency
managers in general.
Composer setup / installation
Note: All commands below need to be run from the same directory where your index.php is located.
First off you'll need to download and install composer. The current version available is 1.8.6. Download this phar to the same location as your index.php script. Also create a composer.json file with {} as the contents, composer will save your dependencies to this file.
Make sure composer.phar has execute permissions (if on linux run chmod +x ./composer.phar)
Run ./composer.phar require coinbase/coinbase. This should install the dependencies within a vendor directory.
Finally, you can require the autoloader composer generates when installing dependencies, and the missing Interface error you are seeing will be resolved.
The composer.json file should contain the following (bare minimum):
{
"require": {
"coinbase/coinbase": "^2.8"
}
}
Example using autoloader
<?php
require_once('vendor/autoload.php');
use Coinbase\Wallet\Client;
use Coinbase\Wallet\Configuration;
$apiKey="";
$apiSecret="";
$configuration = Configuration::apiKey($apiKey, $apiSecret);
$client = Client::create($configuration);

'vendor/autoload.php' errors, composer is installed globally

I installed composer globally and when I run my mail php example I get the following errors:
Warning: require(vendor/autoload.php): failed to open stream: No such
file or directory in
/Applications/XAMPP/xamppfiles/htdocs/emailexample/index.php on line 9
Fatal error: require(): Failed opening required 'vendor/autoload.php'
(include_path='.:/Applications/XAMPP/xamppfiles/lib/php') in
/Applications/XAMPP/xamppfiles/htdocs/emailexample/index.php on line 9
I appreciate any advice on resolving these errors.
I'm afraid you misunderstood what Composer is and what installing it globally means. Composer is a tool for installing dependencies in your project. Installing it globally means that you can use this tool from any place in your system, but it doesn't mean that it will magically resolve all dependencies from all of your project - you need to call Composer manually to declare and install required dependencies.
So if you have composer.json file in /Applications/XAMPP/xamppfiles/htdocs/emailexample you should go into your project directory and install required dependencies:
cd /Applications/XAMPP/xamppfiles/htdocs/emailexample
composer install
If you don't have composer.json you need to define your dependencies first. You can read more about it in documentation, and dependencies should be defined in source of your "mail php example" project. But in general you can add dependencies by:
cd /Applications/XAMPP/xamppfiles/htdocs/emailexample
composer require package/name
Where package/name is name of dependency - you should replace it with real name.
After installing dependencies make sure that you include composer autoloader in your index.php - you should have something like this before using any class:
require_once __DIR__ . '/vendor/autoload.php':

require(vendor/autoload.php): failed to open stream

I know that this issue has been posted many times, but for me it seems to be a different problem.
Indeed, this error
Warning: require(vendor/autoload.php): failed to open stream: No such file or directory in C:\xampp\htdocs\site_web\send_mail.php on line 3
Fatal error: require(): Failed opening required 'vendor/autoload.php' (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\site_web\send_mail.php on line 3
appears at the begining of my code from this line:
require 'vendor/autoload.php';
So, I guess there must be a /vendor/autoload.php file somewhere in my computer (I have installed composer and ran composer require phpmailer/phpmailer).
So, I looked for this file using: dir /s autoload.php in the Windows command line, and found one here: C:\Windows\SysWOW64\vendor\autoload.php,
but for me, syswow64 folder has nothing to see with autoload.php, I don't see what I am missing here.
What you're missing is running composer install, which will import your packages and create the vendor folder, along with the autoload script.
Make sure your relative path is correct. For example the example scripts in PHPMailer are in examples/, below the project root, so the correct relative path to load the composer autoloader from there would be ../vendor/autoload.php.
The autoload.php you found in C:\Windows\SysWOW64\vendor\autoload.php is probably a global composer installation – where you'll usually put things like phpcs, phpunit, phpmd etc.
composer update is not the same thing, and probably not what you want to use. If your code is tested with your current package versions then running update may cause breakages which may require further work and testing, so don't run update unless you have a specific reason to and understand exactly what it means. To clarify further – you should probably only ever run composer update locally, never on your server as it is reasonably likely to break apps in production.
I often see complaints that people can't use composer because they can't run it on their server (e.g. because it's shared and they have no shell access). In that case, you can still use composer: run it locally (an environment that has no such restrictions), and upload the local vendor folder it generates along with all your other PHP scripts.
Running composer update also performs a composer install, and if you do not currently have a vendor folder (normal if you have a fresh checkout of a project), then it will create one, and also overwrite any composer.lock file you already have, updating package versions tagged in it, and this is what is potentially dangerous.
Similarly, if you do not currently have a composer.lock file (e.g. if it was not committed to the project), then composer install also effectively performs a composer update. It's thus vital to understand the difference between the two as they are definitely not interchangeable.
It is also possible to update a single package by naming it, for example:
composer update ramsey/uuid
This will re-resolve the version specified in your composer.json and install it in your vendor folder, and update your composer.lock file to match. This is far less likely to cause problems than a general composer update if you just need a specific update to one package.
It is normal for libraries to not include a composer.lock file of their own; it's up to apps to fix versions, not the libraries they use. As a result, library developers are expected to maintain compatibility with a wider range of host environments than app developers need to. For example, a library might be compatible with Laravel 5, 6, 7, and 8, but an app using it might require Laravel 8 for other reasons.
Composer 2.0 removed any remaining inconsistencies between install and update results; if you're running composer 1.x you should definitely upgrade.
If you get the error also when you run
composer install
Just run this command first
composer dump-autoload
This command will clean up all compiled files and their paths.
#Bashir almost helped me but I needed:
composer update --no-scripts
Apparently this prevents any scripts from being included before executing artisan.
I found the answer here half-way down the page:
https://laracasts.com/discuss/channels/general-discussion/fatal-error-class-illuminatefoundationapplication-not-found-in-pathtoprojectbootstrapappphp-on-line-14?page=0
Proper autoload.php configuration:
A) Quick answer:
Your autoload.php path is wrong. ie. C:\Windows\SysWOW64\vendor\autoload.php
To date: you need to change it to: C:\Users\<Windows User Name>\vendor\autoload.php
B) Steps with example:
We will take facebook/php-graph-sdk as an example; change to Package Name as needed.
Install composer.exe
Open CMD Prompt. + R + type CMD
Run This command: composer require facebook/graph-sdk
Include path in your PHP page: require_once 'C:\Users\<Windows User Name>\vendor\autoload.php';
Define configuration Secrets and Access Token for your package...etc.
Happy codinig.
C) Further details:
Installing composer on windows will set this default path for your pacakges; you can find them there and include the autoloader path:
C:\Users\<Windows User Name>\vendor
For the same question you asked; the answer was this path for WAMP Server 64 BIT for Windows.
Then simply in your PHP Application change this:
require_once __DIR__ . '/vendor/autoload.php';
To:
require_once 'C:\Users\<Windows User Name>\vendor\autoload.php';
Find your windows username under C:\Users\
Before all this, as pointed before in B) , you need to run this command:
composer require <package name>
for facebook php SDK for example:
composer require facebook/graph-sdk
Thank you for asking this question; appreciated as it helped me fix similar issue and ended writing this simple tutorial.
First make sure you have installed the composer.
composer install
If you already have installed then update the composer.
composer update
If you have cloned your project from Github or got it from somewhere else, you will encounter this error. That's because you are missing the vendor folder and other files. The vendor folder contains packages which are dependent to your project. The package dependencies are stored in composer.json file and the folder was excluded while pushing to Github.
Fix this error by simply running:
composer install
Then you will get all the assets needed for your project.
First, review route inside index.php
require __DIR__.'/../vendor/autoload.php';
$app = require_once __DIR__.'/../bootstrap/app.php';
in my case the route did not work, I had to review the directories.
For me
Just run this command first
composer dump-autoload
to add vendor folder.
then run this command
composer update --no-scripts
to update composer.
Create composer.json file with requisite library for ex:
{
"require": {
"mpdf/mpdf": "^6.1"
}
}
Execute the below command where composer.json exists:
composer install
In case of Drupal :
Use the web root folder of drupal to include autoload for ex:
define('DRUPAL_ROOT', getcwd());
require_once DRUPAL_ROOT . '/vendor/autoload.php';
In case of other systems:
Use the root folder variable or location to include the autoload.php
I had this path in my machine:
C:/xampp5.0/htdocs/project-recordando-symfony/project-recordando-symfony
Then I ran composer install or/and composer update and it returned this error:
ErrorException ZipArchive::extractTo...
That error is because your path is too much long, I changed to:
C:/xampp5.0/htdocs/p-symfony/*
and worked!
run composer update. That's it
I was able to resolve by removing composer and reinstalling the proper way. Here is what I did:
sudo apt remove composer
sudo apt autoclean && sudo apt autoremove
Installed globally with the instructions from: https://getcomposer.org/doc/00-intro.md
Download from: https://getcomposer.org/installer
global install: mv composer.phar /usr/local/bin/composer
(Note: I had to move mine to mv composer.phar /usr/bin/composer)
I was then able to get composer install to work again. Found my answer at the bottom of this issue: https://github.com/composer/composer/issues/5510
In your project folder, the vendor folder is missing so you got this error:
Warning: require(vendor/autoload.php): failed to open stream: No such file or directory in
When you download the project through git, the project is downloaded without the vendor folder
You need /vendor because all your packages are there, including all the classes Laravel uses. The vendor directory contains your Composer dependencies.
The solution is simple, Just run this command:
composer update --no-scripts
composer update
composer update --no-scripts It will Skips execution of scripts defined in composer.json file.
composer update It will update your depencencies as they are specified in composer.json file.
With this command, you will re-create the vendor folder in your project and after that your project will start working normally.
This error occurs because of missing some files and the main reason is "Composer"
First Run these commands in CMD
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === 'e0012edf3e80b6978849f5eff0d4b4e4c79ff1609dd1e613307e16318854d24ae64f26d17af3ef0bf7cfb710ca74755a') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
Then
Create a New project
Example:
D:/Laravel_Projects/New_Project
laravel new New_Project
After that start the server using
php artisan serve
In my case, It was due to the non-fully installation of the project, because I didn't have enough space on my hard disk
There will be a directory called "vendor" that needs to be in your root directory if you have a cloned repository and trying to set up that time this type of error occurring.
".gitingore" file has written code to not include vendor directory on GIT so after cloning GIT your project facing the issue of missing vendor directory.
Once you add vendor directory your project will start working again.
Change the auto_prepend_file property on php.ini
; Automatically add files before PHP document.
;http://php.net/auto-prepend-file
auto_prepend_file =
In linux first add github Personal access tokens
Navigate to GitHub's Personal Access Tokens page.
Hit "Generate new token" button.
Type something meaningful "Note", select "repo" as scope and hit "Generate token" button.
Take a note of the token.
5 type in terminal with you new "personal access token"
export COMPOSER_AUTH='{"github-oauth":{"github.com":"AB8cd4cab23a9d5399934a7d7698d3fa74e9cfAB"}}'
Run in terminal composer install

Categories