I am working with AWS CodeBuild, I am facing this issue where I am building a docker image for deployment. However, I am facing this issue where AWS shows me the error message of
Unknown runtime version named '8.0' of php. This build image has the following versions: 7.3, 7.4
However, in the documentation it says that it supports PHP V 8.0.
Note that I am working with Laravel 9.0 with Laravel Sail, MySQL, Redis and MailHog containers.
I am attaching my buildspec.yml file for reference
version: 0.2
phases:
install:
runtime-versions:
php: 8.0
commands:
- echo "PHP Version ⬇"
- php -v
- echo "Initiation of build 🏠"
- echo "Installing Composer 🎺"
- curl -s https://getcomposer.org/installer | php
- mv composer.phar /usr/local/bin/composer
- echo "Installing dependencies 📦"
- composer install
- echo "Installed dependencies 📦"
build:
commands:
- echo "Building 🏗"
- composer build
- echo "Built 🏗"
post_build:
commands:
- echo "Post build 🏗"
- echo "Build completed on `date` 🏗"
Php 8.0 is only supported if you use Ubuntu standard:5.0 CodeBuild image. The fact that you are getting your error, means that you use different image then Ubuntu standard:5.0.
Related
since the latest php fpm docker image update yesterday (https://hub.docker.com/_/php?tab=tags&page=1&name=fpm-alpine) my pipeline is broken because apparently PHP version 8 is installed instead of 7.4 as in my Dockerfile specified.
I am using this in my docker file:
FROM php:7.4-fpm-alpine AS ...
But according to my composer installs the container has PHP 8.0.13 running:
Root composer.json requires php 7.4.26 but your php version (8.0.13) does not satisfy that requirement.
Anyone an idea what is going on here?
As Jeremy Brooks already mentioned, Alpine released version 3.15 where composer requires PHP 8 (https://pkgs.alpinelinux.org/package/v3.15/community/x86_64/composer). Instead of installing composer from getcomposer.org another solution is to use Alpine 3.14:
FROM php:7.4-fpm-alpine3.14 AS ...
The alpine PHP images you reference do not include composer, so how are you installing it? If you are using apk to installer composer, it looks like the latest alpine composer package is pulling php8 in as a dependency, and this is causing your issue. What solved this issue for me was to install composer using the install script from getcomposer.org instead of using apk.
Assuming this is what you are doing, remove this from your Dockerfile:
RUN apk add composer
and add:
ADD https://getcomposer.org/installer ./composer-setup.php
RUN php ./composer-setup.php --install-dir=/usr/local/bin --filename=composer
RUN rm ./composer-setup.php
If composer is indeed included in your base image (unlikely), you could try uninstalling first:
RUN apk delete composer
and then add the above code to install it from the setup script instead.
Edit: adding the ignore-platform-reqs flag will probably get you past the error, but you are introducing a possible point of failure in the future if you have a composer package with a platform requirement. In that case, you won't know about the error until runtime. I would not recommend that approach. The method I posted above will install composer using the version of PHP already on the system and will not require risky workarounds.
I'm currently working on my docker-compose file to install laravel 8 with php 8.
I tested "php:7.4-fpm-alpine", and when I access the container I'm getting this version of php :
/var/www/html # php --version
PHP 7.4.26 (cli) (built: Nov 30 2021 08:21:51) ( NTS )
You can test it yourself :
docker container ls
docker exec -it <container_id> sh
php --version
I'm getting PHP 8.0.13 when installing "php:8.0-fpm-alpine"
Also I'm creating my laravel project using the composer image, I don't have php/composer installed locally. It's something you might have a look, because it could be quickly confusing ;-)
I had the same problem today...
Try:
composer install --no-scripts --ignore-platform-reqs
Fixed it for me.
Code and Idea are from
https://stackoverflow.com/users/564000/armin
I got a website running with laravel framework, this website will need to migrate to public cloud VM. However, I'm not quite familiar with laravel, any suggestion and advice would be appreciated.
I already created a remote VM, and installed Nginx.
Also, I move the root folder from on-prem /var/wwwroot to the cloud /var/wwwroot as well. Moreover, the Mysql database had been imported to the cloud Mysql too (using the dumped .sql file ).
laravel need PHP to run, should I install php5.6 or php5.6-fpm (or both)?
I need to install laravel framework, do I have to install the specific version of lavavel (5.1.46)?
After I install the laravel, do I need to conduct any laravel command such as
~#php artisan migrate ? or just put the wwwroot folder's file should be enough?
Here is more info about the on-prem VM:
~#php --version
PHP 5.6.32-1+ubuntu16.04.1+deb.sury.org+1 (cli)
~#nginx -v
nginx version: nginx/1.13.6
~# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.3 LTS
Release: 16.04
Codename: xenial
~# php artisan --version
Laravel Framework version 5.1.46 (LTS)
~# mysqld --version
mysqld Ver 5.7.20-0ubuntu0.16.04.1 for Linux on x86_64 ((Ubuntu))
Tony.
You want to use NGINX as webserver, so you need to install both packages.
If you install your code from git, you should install dependencies by running command:
php composer install
You should create your .env-file and edit it: set up db connection params and other settings:
cp .env.example .env
Also you should generate app key:
php artisan key:generate
If you copied last version of your db, you don't need to run up migrations, but I recommend you to run new migrations, to be confident that db structure wasn't changed since you make dump.
php artisan migrate
Fatal error: Uncaught Run time Exception: Unable to load application. - Type composer install if you are developing locally. - Type vagrant ssh -c 'composer install' if you are using Vagrant. - Type docker-compose run zf composer install if you are using Docker.
Simply read --"
Type composer install if you are developing locally.
Type vagrant ssh -c 'composer install' if you are using Vagrant.
Type docker-compose run zf composer install if you are using Docker.
I'd like to install the PHP extension OAuth in my build environment on Travis.
I've tried these two configuration in .travis.yml file:
COnfiguration 1 (using before_script):
language: php
matrix:
include:
- php: 5.3
- php: 5.4
- php: 5.5
- php: 5.6
- php: 7.0
- php: hhvm
cache:
directories:
- $HOME/.composer/cache
install:
- travis_retry composer update ${COMPOSER_FLAGS} --no-interaction
script:
- phpunit --verbose --coverage-clover build/logs/clover.xml
- phpenv config-rm xdebug.ini || return 0
before_script:
- pecl install oauth
Configuration 2 (using install):
language: php
matrix:
include:
- php: 5.3
- php: 5.4
- php: 5.5
- php: 5.6
- php: 7.0
- php: hhvm
cache:
directories:
- $HOME/.composer/cache
install:
- travis_retry composer update ${COMPOSER_FLAGS} --no-interaction
- pecl install oauth
script:
- phpunit --verbose --coverage-clover build/logs/clover.xml
- phpenv config-rm xdebug.ini || return 0
The documentation isn't clear about where to put the commands to install custom PHP extensions (or maybe I've not understood it, it's possible!).
Anyway, can someone help me configure Travis to install OAuth PHP extension? Thankyou!
Per Problems with PHP YAML within Travis CI it looks like the pecl install goes in the before_script section.
Per my own testing here https://travis-ci.org/davidjeddy/no-code/jobs/345523220 it appears that does the trick.
i am trying to install yii 2 and to run the basic or advanced application.
i have tried the steps given here Setting up preview of Yii2 to do this.
the steps i followed,
1 - Installed the composer
2 - Use composer to install the app alongwith dependencies(Yii): php path/to/composer.phar create-project --stability=dev yiisoft/yii2-app-basic my_yii2_trial
3 - Access app from http://localhost/my_yii2_trial/web
The problem is, i am getting this syntax error.
Parse error: syntax error, unexpected '[', expecting ')' in D:\xampp\htdocs\my_yii2_trial\vendor\yiisoft\yii2\yii\Yii.php on line 25
can any body help to resolver this issue pls
Yii2 has started using PHP 5.4's Short array syntax. Your error creeps up because of:
spl_autoload_register(['Yii', 'autoload'], true, true);
in Yii.php, which is the new short array syntax. As you have already figured out, you need to install PHP 5.4 now to run Yii2 apps.
The commit which made the changes to short array syntax.
The docs and composer details that have been changed.
The discussion where the decision to move to PHP 5.4 was made.
As Yii2 is still in heavy development, its requirements are also changing. So be sure to read the readme thoroughly before installing.
See also the Backward Incompatible changes list for PHP 5.4, to make changes to your existing code.
Install PHP 5.4 to resolve this issue.
Yii2 Installation Following command:
(1) First install Composer (LINUX):
Locally:
curl -sS https://getcomposer.org/installer | php
OR
(1) First install Composer (WINDOWS):
C:\Users\username>cd C:\bin
C:\bin>php -r "readfile('https://getcomposer.org/installer');" | php
Note: If the above fails due to readfile, use the http url or enable php_openssl.dll in php.ini
C:\bin>echo #php "%~dp0composer.phar" %>composer.bat*
C:\Users\username>composer -V
Composer version 27d8904
(2) Yii2 framework online downloads:
Basic App:
php composer.phar create-project yiisoft/yii2-app-basic basic 2.0.0-beta
Advanced App:
php composer.phar create-project yiisoft/yii2-app-advanced advanced 2.0.0-beta
(3) Other App Settings Command:
php init
php yii migrate
Here is command lines to install yii2 on ubuntu:
cd /var/www
/var/www$ ls
/var/www$ cd myyii2
/var/www/myyii2$ ls
/var/www/myyii2$ ls -al
/var/www/myyii2$ ls
/var/www/myyii2$ php init
/* Your choice [0-1, or "q" to quit] 0*/
choose 0 for developemnt and type yes
php yii migrate (/var/www/myyii2$ php yii migrate)
Before this command need to download advance setup like [yii-advanced-app-2.0.7.tgz]