I've started a new project in which I like to used the current version of PHP (5.5.12). I compiled this version myself because the version of my distro is 5.3.
I need propel ORM so I installed it via composer.
Now, the propel-script uses this shebang:
#!/usr/bin/env php
which of course calls the main PHP (5.3) and not my self-compiled one. Unfortunately propel needs PHP >= 5.4 and I cannot execute the script without errors.
So my quick-and-dirty solution is to replace the first line in the propel-script with:
#!/opt/php-5.5.12/bin/php
which works, but is not update-safe. At least I think this could be replaced by doing a composer-update.I still need the 5.3-version for other projects, so using an alias is no solution for me.
It's maybe some petty problem, but is there a finer way to combine 3rd-party-libraries via composer with a self-compiled php executable?
I would encourage you to use vagrant and setup a virtual machine environment where php5.5 is installed. You could setup an Ubuntu 14.04 for example, it contains PHP version 5.5.
Developing on your physical machine is sooo yesterday! ;)
Related
Please help me, I have developed an application using Yii2 Framework which requires PHP5.6 or greater, and while deployment of the application on the test server I have noticed that on the test server we are using PHP5.5, So please tell me what can I do? The test server is running Ubuntu.
(Minimum requirement of Yii2 is PHP5.6 and we are using PHP5.5)
Thank You.
if I recall correctly, PHP 5.5.X and 5.6.X are not that different. So if you can deploy your application and it runs properly, you should be fine. If you are using composer, it might be harder (or impossible) to spoof your PHP version, though.
My two cents:
You tagged AWS (and therefor probably EC2), so why don't you just update your PHP version? Why don't you run your application on PHP 7.X anyway? It is a great improvement - performance-wise.
You can try a few things...
1) Do you need to have the dev modules from Composer on the test server? If not do a composer install —no-dev
2) Another switch worth trying on the test server is “--ignore-platform-reqs” I don’t recommend it and even though composer install the files the application might not work.
3) If the above isn’t a fix for you, modify your Composer file to put in the constraints of your environments, change your local environment to match the test server, and re-factor the application if necessary. I’d do that instead of rewriting a whole app in Yii1.
You might want to edit your question and add the information about your composer.json file. Do you commit the composer.lock file to source control?
Additionally, not wise for your company to use anything older than PHP 5.6. And PHP 5.6 will have security support ended in Dec 2018. http://php.net/supported-versions.php
Read the following PHP documentation linked below, particularly the backward incompatibility changes and deprecated features. If you use any of those, you need to change your code. If you don't, then you should be fine. You need to test it.
http://php.net/manual/en/migration56.php
I'm working in a project with Symfony Framework, but i have problems with php 7.0. Can I downgrade the php version or I need rewrite the entire application?
Symfony 3 requires at least PHP 5.5.9, so generally speaking, you can downgrade if you want. Of course you might have other limitations, like additional bundles and libraries you have installed and you might have used PHP 7 features inside your own code.
If you want to downgrade you can run:
composer why-not php:5.6
This will tell you which libraries you installed will not work with PHP 5.6. You might be able to downgrade them, but obviously this is not guaranteed and might require changes to how you use those bundles and libraries. For this you will have to check their upgrade guides and "undo" those changes.
For checking your own code you can use tools like etsy's phan to check for compatibility with a specific target version of php: https://github.com/phan/phan#usage
I am returning to php after a long time (although I have a very basic understanding of php in general), and understand that I can run a php server locally by running the command now with version 5.6:
php -S localhost:8080
Do I still need to install XAMP or WAMP as many of the online tutorials are suggesting or am I okay to just use the above command?
Note: I have postgresql installed on my computer already and do not use mysql, if that matters at all
You need a webserver which you prefer depends on you. XAMPP is the most used for private but you could also take a look at BigApache, EasyPHP, PHPTriad, MampServer, WampServer.
Xampp is a combination of below
Apache server
Mysql server
PHP
and others.
This is a pretty famous and most used package. But if you want to install everything manually then thats even better you can control your server in any way you want. Go for it and you will learn more about it.
If you want a very flexible development environment you need to use a package like EasyPHP Devserver (http://www.easyphp.org/) or equivalent.
I'm trying to install zend-escaper but I'm getting this error:
This is strange as my PHP version (from phpinfo()) is 5.5.19, the message claims it is 5.3.5(!) which should satisfy the requirement anyway.
My ZF version is 1.12.13
I'm using PHP Storm
Can anyone help please?
Thanks
Tomasz
The PHP version on the command line can be a different executable than the PHP running inside the web server. It also can use a different pho.ini configuration file.
So if Composer states the PHP it is using is 5.3.5, this is correct because Composer is directly asking the PHP it is running on for its version. The problem is when this PHP version on the command line is way older then the PHP version in the web server.
Try to update your command line PHP.
Some more things to say: the version 5.3.5 is lower than the required 5.3.23, because the last number in the version is 5 compared with 23, and 5 is less than 23. So the version you are using is below the minimum requirement for zend escaper - at least in the version 2.5.1 you try to use. Such an old PHP was last supported in the 2.2 framework versions, so you might as well try to depend on ~2.2. However this will simply be a workaround for the old cli version.
One other note: You are in the process of installing a zend framework 2 component - don't expect your installed zend framework 1 to support any fancy stuff on its own. It is possible to mix classes with namespaces and without, and even use zf2 things together with zf1, but zf1 won't offer any automatic functionality to use these.
I have a dedicated server that hosts a number of websites currently running PHP 5.2. I need to upgrade the PHP version and I have been told I can do this via SSH using this command:
yum upgrade php
No I'm a little concerned about making an update and a website not being able to function any more, so is there a rollback command I can use so that if something does go wrong I can quickly change back to PHP 5.2?
Many thanks
You'd better know what has changes from php 5.2 to php 5.3 first, if you think the changes won't affect you scripts, then upgrade, if not, then stay with php 5.2 or make the necessary changes in your scripts first (Personnaly I do recommand you upgrading to PHP 5.3) , here is the list of changes Migrating from PHP 5.2 to 5.3
If you face some problems after making the upgrade, check the package repository if php 5.2 still exists in it (use the command "yum search php"), if it does then remove the current PHP you got (command "yum remove php") and then install the package you found ( for example : "yum install php-5.2")
Note : If you don't find the PHP 5.2 package in the repository, you may have to compile PHP 5.2 from source.
You can backup the old php version yourself but I cannot recommend this. Usually it's only phpize, php.ini, php.so and the php modules folder. Then you can make the update.