fatal: pathspec 'composer.lock' did not match any files - php

When I use the command:
git add composer.lock
inside the folder of my project I get the message:
fatal: pathspec 'composer.lock' did not match any files
How can I fix this problem?

All I needed to do was install the xml from my php version.
In my case, my version is 7.1, so I did:
sudo apt-get install php7.1-xml
So I used the commands:
composer install
composer update
And finally I was able to add the composer.lock command:
git add composer.lock

Related

getting these erorr while creating laravel project plz some one help me out [duplicate]

When I run a composer update I get this error message:
Loading composer repositories with package information
Updating dependencies (including require-dev)
Failed to download psr/log from dist: The zip extension and unzip command are both missing, skipping.
The php.ini used by your command-line PHP is: /etc/php/7.0/cli/php.ini
Now trying to download from source
What do I need to do to enable the zip and unzip commands so that composer can download dependencies?
Depending on your flavour of Linux and PHP version these may vary.
(sudo) yum install zip unzip php-zip
(sudo) apt install zip unzip php-zip
This is a very commonly asked question, you'll be able to find more useful info in the aether by searching <distro> php <version> zip extension.
For servers with PHP 5.6
sudo apt-get install zip unzip php5.6-zip
Not to belabor the point, but if you are working in a Dockerfile, you would solve this particular issue with Composer by installing the unzip utility. Below is an example using the official PHP image to install unzip and the zip PHP extension for good measure.
FROM php:7.4-apache
# Install Composer
COPY --from=composer /usr/bin/composer /usr/bin/composer
# Install unzip utility and libs needed by zip PHP extension
RUN apt-get update && apt-get install -y \
zlib1g-dev \
libzip-dev \
unzip
RUN docker-php-ext-install zip
This is a helpful GitHub issue where the above is lovingly lifted from.
For Debian Jessie (which is the current default for the PHP image on Docker Hub):
apt-get install --yes zip unzip php-pclzip
You can omit the --yes, but it's useful when you're RUN-ing it in a Dockerfile.
For older Ubuntu distros i.e 16.04, 14.04, 12.04 etc
sudo apt-get install zip unzip php7.0-zip
I had PHP7.2 on a Ubuntu 16.04 server and it solved my problem:
sudo apt-get install zip unzip php-zip
Update
Tried this for Ubuntu 18.04 and worked as well.
I'm Using Ubuntu and with the following command worked
apt-get install --yes zip unzip
In case you're using a locale development environment like XAMPP, just locate the php.ini file (C:\xampp\php in my case), open it and remove the semicolon from the following line.
;extension=zip
Restart your Apache webserver and it will work fine.
On docker with image php:7.2-apache I just needed zip and unzip. No need for php-zip :
apt-get install zip unzip
or Dockerfile
RUN ["apt-get", "update"]
RUN ["apt-get", "install", "-y", "zip"]
RUN ["apt-get", "install", "-y", "unzip"]
If you are using Ubuntu and PHP 7.2, use this...
sudo apt-get update
sudo apt-get install zip unzip php7.2-zip
I got this error when I installed Laravel 5.5 on my digitalocean cloud server (Ubuntu 18.04 and PHP 7.2) and the following command fixed it.
sudo apt install zip unzip php7.2-zip
For PHP8.2 (Windows)
As stated here: https://www.php.net/manual/en/zip.installation.php#zip.installation.new.windows
As of PHP 8.2.0, php_zip.dll DLL must be enabled in php.ini. Previously, this extension was built-in.
You will need to manually enable this extension within your php.ini by adding extension=php_zip.dll
For a list of installed extensions you can run:
php -m
or if you have grep installed even easier would be:
php -m | grep "zip"
Actually composer nowadays seems to work without the zip command line command, so installing php-zip should be enough --- BUT it would display a warning:
As there is no 'unzip' command installed zip files are being unpacked using the
PHP zip extension.
This may cause invalid reports of corrupted archives. Installing 'unzip' may
remediate them.
See also Is there a problem with using php-zip (composer warns about it)
PHP-ZIP needs some dependancies or library missing, depends on the image from Dockerfile you need to install them first
RUN set -eux \
&& apt-get update \
&& apt-get install -y libzip-dev zlib1g-dev \
&& docker-php-ext-install zip
PHP 8.1
apt-get install --yes zip
The shortest command to fix it on Debian and Ubuntu (dependencies will be installed automatically):
sudo apt install php-zip
Try this for PHP 7.4:
sudo apt-get install zip unzip php7.4-zip
And for PHP 8.0:
sudo apt-get install zip unzip php8.0-zip
After run
apt install php-zip
and run again
composer require ...
I get the next warning and suggestion
As there is no 'unzip' nor '7z' command installed zip files are being unpacked using the PHP zip extension.
This may cause invalid reports of corrupted archives. Besides, any UNIX permissions (e.g. executable) defined in the archives will be lost.
Installing 'unzip' or '7z' (21.01+) may remediate them.
As there is no 'unzip' nor '7z' command installed zip files are being unpacked using the PHP zip extension.
This may cause invalid reports of corrupted archives. Besides, any UNIX permissions (e.g. executable) defined in the archives will be lost.
Installing 'unzip' or '7z' (21.01+) may remediate them.
So I suggest install unzip first.
apt install unzip
Please check your composer status first
composer diagnose
If the status showing
zip: extension not found, unzip not available, 7-Zip not available
then
Open your XAMPP Server
Apache -> config button ->Click "PHP(php.ini)"
Find "zip"
";extension = zip will shown
Remove the semicolon and save the file
Restart your XAMPP Apache
Now
composer create-project laravel/laravel <<project_name>>
or
laravel new <<project_name>>
apt-get install zip
I'm running a docker container and this helped me
docker-compose exec app apt-get install zip
install 7 zip from this site https://www.7-zip.org/download.html this software unzips the files for you and solvesd the errors

Laravel 5.5 fail when serve

5 project and after install Laravel and make php artisan serve it fails.
PHP Warning: require(/var/www/html/sidbrint/vendor/autoload.php):
failed to open stream: No such file or directory in
/var/www/html/sidbrint/artisan on line 18
PHP Fatal error: require():
Failed opening required '/var/www/html/sidbrint/vendor/autoload.php
(include_path='.:/usr/share/php') in /var/www/html/sidbrint/artisan on
line 18
I'm using an Ubuntu Server and I don't know hat to do.
When I install Laravel I use composer create-project --prefer-dist laravel/laravel blog "5.5.*"
If I don't put the version, it installs the 5.4 version, that works fine, but I need version 5.5 because is LTS.
Try using this it might solve your issue
composer update --no-scripts
composer update
is required as the vendor files are missing.
Seems that I needed some PHP packages, so I installed them:
sudo apt-get install php-dev php-mcrypt php-gd php-mbstring php-xml php-common php-zip apache2-dev libapache2-mod-php mysql-server composer npm
After this I executed composer create-project --prefer-dist laravel/laravel blog "5.5.*" and worked fine.
I have consulted this:
How to Install Laravel 5.5 on Ubuntu 16.04 with Apache

Installing laravel ( sh: 1: composer: not found) error

I've been trying to install laravel on Ubuntu 14.04. I finished all the steps, but when try to
laravel new mySite
the following message is deployed:
Crafting application...
sh: 1: composer: not found
Application ready! Build something amazing.
It's looks like some trouble with composer, but I don't know why. Composer seems to work, so, what is wrong? Thank you!
I got the same error.
I fixed it with simple symlink.
locate it. Run: # whereis composer
composer: /usr/local/bin/composer.phar
then create link: # sudo ln -s /usr/local/bin/composer.phar /usr/local/bin/composer
Thats it. All works.
If you run composer on shell, does it run? otherwise run:
sudo apt-get install curl php5-cli git
curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer
Then try again, maybe you could try the composer installation syntax:
composer create-project --prefer-dist laravel/laravel blog
To be sure composer is updated to the latest version and nothing is in cache run:
composer self-update
composer clear-cache
I still can't use laravel new, but I found what was happening with composer.
Laravel 5.3 needs php5.6 or higher, otherwise will run an older laravel version. I upgrade to php5.6 with this steps: https://www.dev-metal.com/install-setup-php-5-6-ubuntu-14-04-lts/
then run
composer create-project laravel/laravel ProjectName
and it's done!

How to install Laravel 5.2

I am installing the Laravel framework in directory /var/html/www, using command
php composer.phar global require "laravel/installer"
It changes installation directory automatically, shown message is:
Changed current directory to /home/.composer
What is the reason? Do I need to add any other command?
This is because you installed the Laravel installer with global, which makes it globally available for all projects and installs it to /home/.composer.
This should be all right because it is only Laravel's installer and not a Laravel project which should be created in a later step (see below) and this should be installed in your /var/html/www then.
Run the following command in your /var/html/www to create a new project (doesn't need Laravel installer):
composer create-project --prefer-dist laravel/laravel YourProjectName 5.2
or use the Laravel installer
laravel new YourProjectName
For more info how to install Laravel see the documentation here.
Let use
composer create-project --prefer-dist laravel/laravel project_name "5.2.*"
1) change the permission of your directory to allow CRUD.
Open Terminal and paste this command
sudo chmod -R o+rw /var/html/www
2) update the package manager cache by running:
sudo apt-get update
3) cd to your directory to check if composer json does exist
cd /var/html/www
and type
composer
4) To install composer in your directory run
curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer
5) To test if it's installed run
composer
6) Now install laravel 5.2 in your directory (/var/html/www)
composer create-project laravel/laravel ProjectName 5.2 --prefer-dist

Laravel - Unable to open composer.phar file

Hey just started working on laravel. First day for me. Not much idea. Step by step following the steps from documentation given by https://www.laravel.com
After installing composer on my desktop at root folder. As soon, i opened composer.phar, it showed this error -> there is a problem opening the file "/root/composer.phar"
I followed steps given in https://getcomposer.org/doc/00-intro.md#installation-linux-unix-osx .
apt-get install curl
apt-get install php5-cli
curl-sS https://getcomposer.org/installer | php
php composer.phar
Is there any problem ? Please help me........
For installing composer try follow this
sudo apt-get install curl
curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer
sudo chmod +x /usr/local/bin/composer
Setting up Laravel
Run only composer and see if composer is installed.
If yes then let's install laravel installer to quickly install laravel. Run this command from your command line composer global require "laravel/installer=~1.1"
Now if you are using zsh then add this line to user home directories .zshrc file export PATH="~/.composer/vendor/bin:$PATH"
Else add this lines to .bashrc file export PATH="~/.composer/vendor/bin:$PATH"
Now you can run laravel new blog and a new laravel installation will be downloaded.
Now run php artisan serve from that directory to serve your laravel
See http://laravel.com/docs/5.1/#installation for more details
Tips: You can create a separate file and include it to your
.zshrc or .bashrc

Categories