Php update (Package 5.5-frontenddev is already installed)? - php

I am trying to update my Php to 5.5 on a mac (by pasting "curl -s http://php-osx.liip.ch/install.sh | bash -s 5.5" into terminal). The download starts but gives the following message before the downloads stops:
Package 5.5-frontenddev is already installed at version 5.5.5-20131020-233829. You wanted to install version 5.5.5-20131020-233829.
Is there anyway around this as I really need 5.5 in order to continue with my course!
Thank you in advance for any help.
Margate

You should be able to delete the packager registry log and just try the command again, making sure you have removed the relevant folders from /usr/local/php5-*.
The file is located at:
/usr/local/packager/registry.log

Related

How to upgrade to PHP 7.0 on macOS Sierra?

I tried to update my PHP version on my mac but I am facing some issues
When i use cURL it freezes and it will never complete the download on the terminal:
This is the cURL command that I am running is: curl -s https://php-osx.liip.ch/install.sh | bash -s 7.2
I tried to download a package manually but I can't extract it or even know how to install it.
You can use home-brew for installation / https://medium.com/#romaninsh/install-php-7-2-on-macos-high-sierra-with-homebrew-bdc4d1b04ea6 , I find it quite better then managing with Mac OS build in PHP
I don't have enough details so I will go in blind guess here.
First judging by screenshot it is stuck on downloading. For how long it was frozen? Maybe you didn't wait enough.
When you downloading the source what you need to do is:
Assuming you downloaded package with name php-7.2.6.tar.gz from PHP Official website.
Execute command tar xzf php-7.2.6.tar.gz from command line. (assuming you are in the same directory as file). It will unpack it in directory called php-7.2.6.
Enter the directory with command cd php-7.2.6.
Enter in terminal ./configure. It will take a while, so make sure to get some coffee.
After ./configure finished, execute command make. This will take a while as well, so you might get a sandwich.
Once command finished executing the last step will be executing command make install. It will be quicker than others, don't worry. After that you will be able to execute php command.
Optional Run make test to make sure everything is fine.
PHP has been installed, HOORAY!
Hope that helped, have a nice day. And if I answered your question, please mark it 'Answered`.

How to change PHP version used by composer

I want to use another php version on my machine than the one already installed using WAMP (2 PHP version installed).
The composer installed uses PHP 5.6
A new project requires PHP7.0.
Whenever I choose PHP 7 from the control panel of WAMP and then run php -v it still printing PHP5.6 (CLI)... instead of PHP7.
How can I use PHP7 without reinstalling the composer again?
You can change php version of composer without uninstalling it, follow these steps :
Search for system environment variables in cortana.
Click on the button "Environment variables".
Under "System variables" select path and click on edit, you will see one entry like this "C:\wamp\bin\php\php5.6.13".
Just change this to the folder name of the php located at your wamp/bin/php7.1.9, here php7.1.9 is folder name.
Replace php5.6.13 with bin7.1.9, it will look like these "C:\wamp\bin\php\php7.1.9", just click ok on all the boxes.
You are done.
To verify, first close all the cmd windows, than open cmd and type php -v, press enter and you should see php7.1.9.
If you don't see change in php version than just restart your pc and run php -v again in cmd , it will work.
I'm assuming Windows if you're using WAMP. Composer likely is just using the PHP set in your path: How to access PHP with the Command Line on Windows?
You should be able to change the path to PHP using the same instructions.
Otherwise, composer is just a PHAR file, you can download the PHAR and execute it using any PHP:
C:\full\path\to\php.exe C:\full\path\to\composer.phar install
If anyone is still having trouble, remember you can run composer with any php version that you have installed e.g. $ php7.3 -f /usr/local/bin/composer update
Use which composer command to help locate the composer executable.
I found a very easy way to switch php versions:
Search for system environment variable
Click on "Environment variables"
Under "System variables" select path and click on edit
Move the PHP version folder you want to use before the other one.
So for example: php 7.0 will now be used:
Close all windows by clicking "OK"
Close all the cmd windows, than open cmd and type php -v
You will see the correct php version loaded now:
Another possibility to make composer think you're using the correct version of PHP is to add to the config section of a composer.json file a platform option, like this:
"config": {
"platform": {
"php": "<ver>"
}
},
Where <ver> is the PHP version of your choice.
Snippet from the docs:
Lets you fake platform packages (PHP and extensions) so that you can emulate a production env or define your target platform in the config. Example: {"php": "7.0.3", "ext-something": "4.0.3"}.
This is what happens in my case. I hope this may help to someone have same situation. I'm using macOS Monterey with MAMP.
I linked the php 7.4 using ~/.profile file. So the terminal it says I'm using php 7.4. However, still my composer giving an error saying i'm using php 7.3.
So I check the php path using
which php
This gives me the /usr/local/bin/php as my php cli location. So I remove the file and made a symlink to my php7.4 and now working perfectly.
sudo rm -rf /usr/local/bin/php
sudo ln -s /Applications/MAMP/bin/php/php7.4.21/bin/php /usr/local/bin/php
I found out that composer runs with the php-version /usr/bin/env finds first in $PATH, which is 7.1.33 in my case on MacOs.
So shifting mamp's php to the beginning helped me here.
PHPVER=$(/usr/libexec/PlistBuddy -c "print phpVersion" ~/Library/Preferences/de.appsolute.mamppro.plist)
export PATH=/Applications/MAMP/bin/php/php${PHPVER}/bin:$PATH
Old question I know, but just to add some additional information:
WAMP is used only on Microsoft Windows Operating Systems.
Changing the version of PHP used through the left-click -> PHP -> Version menu changes the version used by Apache to server your site.
Changing the version of PHP used through the right-click -> Tools -> Change PHP CLI Version menu changes the version used by WAMP's PHP CLI.
Note: It is important to understand that the "PHP CLI Version" is used by WAMP's own internal PHP scripts. This "PHP CLI Version" has nothing to do with the version you wish to use for your scripts, Composer or anything else.
For your scripts to work with the version you require, you need to add it's path to the Users Environmental Path. You could add it to the Systems environmental Path but the Users Path is the recommended option.
From WAMP v3.1.2, it would display an error when it detect reference to a PHP path in the System or User Environmental Path. This was to stop confusion such as you were experiencing. Since v3.1.7 the display of this error can now be optionally displayed through a selection in the WampSettings menu.
As indicated in previous answers, adding an installed PHP path (such as "C:\wamp64\bin\php\php7.2.30") to the Users Environmental Path is the correct approach. PS: As the value of the Users Environmental Path is a string, all paths added must be separated with a semi-colon (;)
After experiencing the exact same problem (IE: Choosing which version of PHP I wanted Composer to use), I created a script which could easily and rapidly switch between PHP CLI Versions depending on what project I was working on.
The Windows batch script "WampServer-PHP-CLI-Version-Changer" can be found at https://github.com/custom-dev-tools/WampServer-PHP-CLI-Version-Changer
I hope this helps others.
Good luck.
After a long search on the internet and finding many unrelated answers / ones that did not work for me, Here is what worked for me.
Those who are in shared hosting know that bin directory is write-protected and running sudo commands or any system-wide command is not allowed.
There's two ways of solving this:
Run the command directly on your project folder selecting the appropriate PHP version you need.
ea-php80 /opt/cpanel/composer/bin/composer update
To get available PHP on your server type ea-php and hit TAB to see a list.
make an alias to composer
Run this command to edit/make this file nano ~/.bashrc
Inside that file, put alias composer="ea-php80 /opt/cpanel/composer/bin/composer"
This gives you the flexibility to run composer commands as usual without those long trailing strings
If you are using Windows, all you have to do is change the path to php.exe in the composer.bat file located in: "C:\ProgramData\ComposerSetup\bin".
In my case I include paths to all php versions, whenever I need to run a project on a specific php version, I just move the required path to the top (using these buttons in the right) and then close all the terminals and restart my wampp server.
The path with listing in the will be selected as your php version by windows
This is the simplest solution I think.
If you still facing the problem after changing Environment variables in windows, try to delete directory or just rename directory of your old php.
I've done it and it's work.
I will assume that you need this because a requirement to have multiple php versions installed to handle multiple projects.
If this is the case a prefer to run directly the php desired bin pointing to the executable script of composer, for example, in my case I have php 8.1 and 7.4, my main php version configured for CLI is 8.1, but I want to run composer with 7.4 in some projects, so I run this command:
php7.4 -f /usr/local/bin/composer install
Where php7.4 is the bin installed and my global composer script is in /usr/local/bin/composer
From there, you can make an alias like this to facilitate things: alias composer7.4='php7.4 -f /usr/local/bin/composer ' so next time you need to run composer with php#7.4 you only need to run: composer7.4 install
Came here by the title, but the question specifies WAMP; which this may not easily apply to. So, in my case - using a Mac.. so more like a MAMP - if you have brew and the below versions installed, this could help - and composer picks it up.
brew link --overwrite --force php#8.1
php -v
#PHP 8.1...
brew link --overwrite --force php#7.4
php -v
#PHP 7.4...

Facing problems while installing Laravel v4.2 on windows 7

I am facing problems while installing Laravel on windows 7.
I am using Xampp and installed composer, added the path in the system variable. But when I run "composer install", I found this problem...
Composer could not find the config file
C:\ProgramData\ComposerSetup\bin To initialize a project, please
create a composer.json file as described in the
http://getcomposer.org/, "Getting started section"
I don't know what I have to do now. Please help.
Thanks in advance.
Try curl -sS https://getcomposer.org/installer | php or php -r "readfile('https://getcomposer.org/installer');" | php for a clean install.
If nothing works download this.
You can download Putty to run this commands.
(Make sure your XAMPP or whatever program you are using is running!)

Install Composer without curl (local)

I have to run a Laravel Project on a customers Server, Mcrypt is already installed but I can't run "composer install" because composer is missing. Problem here is, that I can't run
curl -sS https://getcomposer.org/installer | php
because I don't get a connection to other server "outside".
So does anybody know, if I can save the file local and upload it with FTP and run it?
Already tried to save the /installer as a file and run it with "asdf | php" but it didn't work. I also downloaded the composer.phar file but how do I run the .phar file?
Thanks!!
Downloading the composer phar file as you have done is a sufficient alternative.
Usage:
php composer.phar command
Docs: https://getcomposer.org/doc/01-basic-usage.md
However, I am fairly sure composer depends on curl, at least as far as updating/installing packages goes. So if you're intending to use those features you'll need curl anyway.*
*citation needed.
edit:
I am currently looking through the composer source and I can't yet find a reference to curl. It appears to use stream_context_create, and the manual page for that method doesn't mention curl either. So maybe it'll work without curl...

How to install PHPUnit with WAMP?

I'm a newbie programmer and I have tried for an embarrassingly long time to get PHPUnit set up and working with WAMP. I have read the documentation and went through various sites to see what I'm doing wrong, but I give up! I need someone to explain this to me in simple terms.
I've probably seen all the guides on how to set it up, but feel free to link me to something you believe is foolproof!
Try this blog : http://nishutayaltech.blogspot.com/2011/04/installing-phpunit-on-windows.html
This setup is for Windows. Hope this will help you.
Also check this out, may be useful http://www.mark-leong.com/installing-php-and-phpunit-on-windows-7/
// adding required pear channels
pear channel-update pear.php.net
pear upgrade-all
pear channel-discover pear.phpunit.de
pear channel-discover components.ez.no
pear channel-discover pear.symfony-project.com
pear update-channels
// performing install
pear install --alldeps --force phpunit/PHPUnit
If everything ok, check whether phpunit have been installed by putting in command line
phpunit -v
If you encountered any errors or interrupted installing
pear clear-cache
may be usefull in that case.
1) download https://phar.phpunit.de/phpunit.phar
2) run it via php phpunit.phar
Btw if that file ever goes away you can look at the original directions here: https://github.com/sebastianbergmann/phpunit
I recommend using composer. It can be used per project, but also 'globally'.
Make a folder on your C drive called 'globalpackages', then cd into it from the command line.
run 'composer require phpunit/phpunit'
once that finishes run 'composer install'
once that finishes you can check the contents of C:\globalpackages\vendor\phpunit' and should see two phpunit files, one of them a bat.
Add C:\globalpackages\vendor\phpunit to your system path and then you will be able to run phpuni from anywhere on your system.
For me this is the fastests and easiest way.
Make sure you have wamp with WAMP with PHP 7 installed as phpunit requires PHP7 to work! or at least 6.2
Go to folder
wamp64\bin\php\php7.0.10
(wherever you installed your wamp - BEWARE last folder is name of PHP version you have so it might be different then above )
We will be working in this folder during entire installation. So if I say edit file etc it means in this folder.
Download newest version of phpunit from https://phpunit.de/
At the time of writing this I get version phpunit 6.2 and php7.0.10
4. Copy downloaded file to wamp64\bin\php\php7.0.10 folder
For me it's: phpunit-6.2.2.phar
for you it might be different version.
Now change name of the phpunit-6.2.2.phar to phpunit.phar
Now make sure you have added your php to PATH in Environment Variables
To do this on Windows 10 and Windows 8
6a. In Search, search for and then select: System (Control Panel)
6b. Click the Advanced system settings link.
6c. Click Environment Variables. In the section System Variables, find the PATH environment variable and select it. Click Edit. If the PATH environment variable does not exist, click New.
6d. In the Edit System Variable (or New System Variable) window, specify the value of the PATH environment variable. Paste location of your PHP. For me it would be: D:\AnyFolderYouInsalledWampTo\wamp64\bin\php\php7.0.10
(if in PATH there was other command or path just add ";" at the end. For exmaple:
%someOtherCommand%; D:\AnyFolderYouInsalledWampTo\wamp64\bin\php\php7.0.10)
6e. Click OK. Close all remaining windows by clicking OK.
In cmd (to run cmd go to search in Windows and type cmd.exe and click Enter)
go to folder wamp64\bin\php\php7.0.10
(to go to folder type for example cd D:\AnyFolderYouInsalledWampTo\wamp64\bin\php\php7.0.10)
now once you are in this folder run this command in cmd:
echo #php "%~dp0phpunit.phar" %* > phpunit.cmd
now run this command:
phpunit
you should get list of all commands available in phpunit
now run this:
phpunit --check-version
you will get info what phpunit version you have and if you are using the newest version.
if this doesn't work go to wamp64\bin\php\php7.0.10
Edit file phpunit.bat
Add this line:
""%PHPBIN%" "D:\AnyFolderYouInsalledWampTo\wamp64\bin\php\php7.0.10\phpunit.phar" %*
Repeat point 9.
if it still doesn't work let me know.
Very well done, Emil! You're a star! Perfect answer to install PHPUnit with WAMP on Windows. Look no further than Emil.
https://stackoverflow.com/users/5753967/emil

Categories