Conflicting versions of composer installed package causing issues - macos

I'm running mac OS X and trying to use codeception through the terminal for a laravel project I'm working on, but I'm having some issues related to the version. The codecept command through terminal is referencing an older version and I cannot figure out how to change the reference to the newer one.
When I type in codecept -v in terminal it shows 2.1.6. However, when I type in ./vendor/bin/codecept it shows 2.4.1. So, every time I need to use codeception I now have to type ./vendor/bin/codecept some_command, which is quite aggravating.
How can I change it so that I don't have to type out ./vendor/bin/codecept every single time I need to run a codeception command and can instead just use codecept, which the older version is currently referencing? I tried using export PATH=$PATH:./vendor/bin/codecept but that didn't do anything.

Try run:
export PATH=./vendor/bin:$PATH
It will prefer binaries from local composer installation.
You may want to add it to your ~/.profile or ~/.bashrc file, then you will not need to run this command in every session.
If your global Codeception installation is installed by Composer, you should be able to update it by:
composer global require codeception/codeception
But I would not recommend to use global installation - required Codeception version may vary for different projects, so using version installed locally should give you less trouble and more predictable results.

what worked for me is:
Install Composer
Navigate to your desired location and copy this set of commands in your terminal:
php -r "copy('https://getcomposer.org/installer',
'composer-setup.php');"
php -r "if (hash_file('SHA384', 'composer-setup.php') ===
'669656bab3166a7aff8a7506b8cb2d1c292f042046c5a994c43155c0be6190fa0355160742ab2e1c88d40d5be660b410')
{ echo 'Installer verified'; } else { echo 'Installer corrupt';
unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
Install latest Codeception via Composer:
In terminal type:
composer require codeception/codeception --dev

Related

Laravel: [ErrorException] "continue" targeting switch is equivalent to "break". during "composer install"

When I run ...
composer install
... on a server with PHP and nginx installed.
I get the following exception:
[ErrorException]
"continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"?
How can I fix this?
This is a new warning introduced in PHP 7.3.
It means you are not allowed to have a continue statement inside of a switch, you should use break instead.
To fix this you most likely just have to update composer, this can be done simply by running composer self-update.
You can also just run php without warnings, this can be done by setting the ini config values as a start parameter.
php -d error_reporting=0 composer.phar
Check your current PHP version if it's greater than 7.2, then execute follow below simple steps
1. Disable the latest php version
sudo a2dismod php7.3
2. Restart the nginx service
sudo service nginx restart
3. If you are using Apache2 run as below
sudo service apache2 restart
4. Set alternatives
sudo update-alternatives --set php /usr/bin/php7.2
5. Check the PHP version
php -v
6. Now, Install Composer as below
composer install
Old composer uses continue statement in their code within the switch which is outdated and cannot be used anymore with latest version of php.
you need to update your composer
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php composer-setup.php --install-dir=bin
for more details visit composer download
It was because of an outdated composer. After searching a lot finally the following works for me:
Uninstall the old composer.
Install a new updated composer.
You can download or install composer from this link: https://getcomposer.org/download/
For me,
just go to this file
sudo nano /usr/share/php/Composer/DependencyResolver/RuleSetGenerator.php
As a quick and dirty alternative, you can fix the error in that file. Just replace "continue" with "break"

Composer doesn't work after global installation

I'm a newbie. I've searched all over the place to find a solution for my issue but unfortunately couldn't find it. So hopefully somebody on here can tell me what I'm doing wrong or what I missed.
I installed composer on my local machine (MacBook Pro).
I've made it global and when I go to /usr/local/bin I can see the file composer.phar
On my desktop I've created a folder teamleader-api. I want to make a WordPress plugin that uses service API's.
As library I want to use https://github.com/sumocoders/Teamleader
On the instructions that I found they say that I need to go to my plugin directory.
$ cd /Users/myname/Desktop/teamleader-api
The library says that to install I need to use composer require sumocoders/teamleader
$ composer require sumocoders/teamleader
But when I give in this command in my terminal I get
-bash: composer: command not found
What am I doing wrong?
I found my solution....just needed to watch the next youtube video :-)
I explain what I did so people who might have the same issue in the future know what to do.
In terminal I went to my teamleader-api folder who is on my desktop.
From https://getcomposer.org/ I copied the code
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('SHA384', 'composer-setup.php') === '544e09ee996cdf60ece3804abc52599c22b1f40f4323403c44d44fdfdd586475ca9813a858088ffbc1f233e9b180f061') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
Instead of composer require sumocoders/teamleader I need to use php composer.phar require sumocoders/teamleader
And now it works....easy as pie :-)

Composer: Command Not Found on Mac

I have installed Composer as per the instructions command not found
After installing I get the prompt that Composer is successfully installed but when I go to check the version it gives me error "Composer: Command Not Found"
I have been looking how to fix this issue and I had to read and understand little bit and the environment variables on MAC.
I understand the issue looks simple but it will get over complicated if you didn't understand how to install composer probably.
Solution 1
I found this solution here: https://duvien.com/blog/installing-composer-mac-osx
Open a terminal and navigate to your user directory, ie cd /User//
Run this command shown below to download Composer. This will create a Phar (PHP Archive) file called composer.phar:
curl -sS https://getcomposer.org/installer | php
Now we move composer.phar file to a directory
sudo mv composer.phar /usr/local/bin/
We want to run Composer with having to be root al the time, so we need to change the permissions:
sudo chmod 755 /usr/local/bin/composer.phar
Next, we need to let Bash know where to execute Composer:
nano ~/.bash_profile
Add this line below to bash_profile and save
alias composer="php /usr/local/bin/composer.phar"
and then run this command:
source ~/.bash_profile
Finally, run:
composer --version
Solution 2:
I understand that the first command you will find online when you try to google this issue would be
curl -sS https://getcomposer.org/installer | php
But actually this is the main terminal installation but sometimes I wanted to manually install the composer, so this 2nd solution about manually installing the composer in specific directory
First of all you need to understand where are you now on the terminal
use
pwd
and then install composer manually using the following commands
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') ==='baf1608c33254d00611ac1705c1d9958c817a1a33bce370c0595974b342601bd80b92a3f46067da89e3b06bff421f182') { echo 'Installer verified'; } else { echo 'Installer corrupt';
unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
to use it on that case you will read on the terminal to use this composer installation use
Use it: php composer.phar
so just write
php composer.phar
and it should be working.... one more thing, during this installation you can install the composer to specific directory / project folder... in that case you can use a flag with command No.4 to tell the terminal to install the composer in specific directory...this flag is --install-dir=your-directory-path
and you will the terminal this time after installing composer asking you to use the following path to call the composer
Use it: php /Users/muatafa/composer.phar
if you want to read more about this issue, I think you must read the composer documentation how to install it>>> https://getcomposer.org/download/
that's how I solved my current issue... if you still have any issues comment on this replay & Hopefully we can figure it out!
I had the same problem. "composer require something" works if installed in global and not locally.
If you install composer locally you'll then install dependencies using "php composer.phar require nameofyoudependency"
To install globally open a terminal to install as mentionned on the composer website. Then run "sudo mv composer.phar /usr/local/bin/composer"
Now you can use "composer" directly to install dependencies like => "composer require something/sdk"
the composer you installed is still named /usr/local/bin/composer.phar - look in the second yellow/brownish line in your output. Just rename it to just composer
Your composer command is not set to path, use
export PATH=$PATH:/usr/local/bin/
I had the same issue, After installing composer using the command line on their website. I forgot to put composer.phar into a directory on my PATH, so it can simply be called from any directory (Global install). and then I ran this command "sudo mv composer.phar /usr/local/bin/composer" and it was resolved
I figured out. in place of "composer require twilio/sdk" I needed to use
"composer.phar require twilio/sdk" since I am on mac. It worked

Laravel Installer method

Normally I do install Laravel 5.1 by following this command regarding to documentation:
composer create-project laravel/laravel --prefer-dist
It works fine.
But I read in the documentation under "Via Laravel Installer" also it is possible to install via Laravel Installer, which is much faster than installing via Composer:
laravel new blog
But to use this method I need to run following command once:
composer global require "laravel/installer=~1.1"
When I do run it I get following errors many times
Deprecation Notice: Composer\Package\Version\VersionParser::parseLinks
is deprecated. Use \Composer\Package\Loader\ArrayLoader::parseLinks()
instead in
phar://C:/ProgramData/Composer/bin/composer.phar/src/Composer/Package/Version/VersionParser.php:226
after many line of same error ./composer.json has been updated appears and it continues with the same line of errors, it ends with following
Loading composer repositories with package information Updating
dependencies (including require-dev) Nothing to install or update
Generating autoload files
What is wrong with it? Any idea or solution.
My environment: Windows 10, GitBash and cmder console.
Update of composer, I did ran composer self-update also
Snapshot of console
EDIT:
Note, I can confirm after solving the issue that the installation via Laravel Installer method is faster than composer.
The Composer Assets Plugin you've installed locally is using a deprecated method of Composer. The plugin is already fixed, so run composer global update to get the latest versions with the bug fix. After it, you should be able to run the command succesfully.
If this doesn't work (as you might get the same error running the previous command), try removing the global vendor directory. When running any global Composer command, it outputs something like "Changed current directory to XXX". Remove the XXX/vendor directory and then try running the command.
In addition to #WouterJ answer.
Worst case if the steps provided by #WouterJ did not work, you could manage to uninstall and reinstall composer for windows.
When done, run composer global update to be sure to get latest updates, if there was.
Then run composer global require "laravel/installer=~1.1" and it should works.
Remember to update your windows environment path C:\Users\UserName\AppData\Roaming\Composer\vendor\bin

creating new laravel application on mac by laravel installer

I have been strugling to create an application with laravel installer from terminal.
I have globally installed composer and laravel..
however i constantly get this error:
If you check at the bottom of the screenshot you can see -bash: new: command not found however laravel command is being executed perfectly. My osx version is 10.10.2. Macbook pro.
Any help will be appreciated.
Another question (bit out of the topic)
Is git inbuild in mac osx?
Cuz i hadn't installed it but it shows all of its commands.
Regards,
=======================
I created alias for composer and laravel in .bash_profile and .bashrc and it worked however now I'm getting this error :
Prajwols-MacBook-Pro:htdocs prajwol$ laravel new test
Crafting application...
Warning: ZipArchive::extractTo(): Invalid or unitialized Zip object in /Users/prajwol/.composer/vendor/laravel/installer/src/NewCommand.php on line 99
Warning: ZipArchive::close(): Invalid or unitialized Zip object in /Users/prajwol/.composer/vendor/laravel/installer/src/NewCommand.php on line 101
Application ready! Build something amazing.
Result : An empty folder is created called test in destination folder.
The command needs a project name: laravel new <NAME>. Like laravel new blog. This will create a new laravel project in a new blog directory in the current path.
$ brew tap homebrew/homebrew-php
$ brew install php72
Install composer
$ php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
$ php composer-setup.php --install-dir=/usr/local/bin --filename=composer
Install Laravel
$ composer global require "laravel/installer"
$ composer global -vvv require "laravel/installer"
now run command
composer

Resources