When loading my AWS Elastic Beanstalk test website using CodeBuild continual deployment, I get this error:
Warning: require(/var/app/current/clu/public/../vendor/autoload.php): failed to open stream: No such file or directory in /var/app/current/clu/public/index.php on line 24 Fatal error: require(): Failed opening required '/var/app/current/clu/public/../vendor/autoload.php' (include_path='.:/usr/share/pear7:/usr/share/php') in /var/app/current/clu/public/index.php on line 24
It seems like the composer files are not being generated.
However, in the CodeBuild logs, they are.
[Container] 2020/02/24 03:21:34 Running command composer install
03:21:38
Loading composer repositories with package information
03:21:38
Installing dependencies (including require-dev) from lock file
03:21:38
Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. It is recommended that you run `composer update` or `composer update <package name>`.
03:21:38
Package operations: 89 installs, 0 updates, 0 removals
03:21:38
- Installing doctrine/inflector (v1.3.0): Downloading (connecting...)Downloading (100%)
03:21:38
- Installing doctrine/lexer (1.1.0): Downloading (connect..
...
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> #php artisan package:discover --ansi
Discovered Package: [32mfacade/ignition[39m
Discovered Package: [32mfideloper/proxy[39m
Discovered Package: [32mlaravel/tinker[39m
Discovered Package: [32mnesbot/carbon[39m
Discovered Package: [32mnunomaduro/collision[39m
[32mPackage manifest generated successfully.[39m
This is my buildspec.yml code:
version: 0.2
phases:
install:
commands:
export DEBIAN_FRONTEND=noninteractive
#Install php7.1
apt-get update
apt-get install -y software-properties-common
LC_ALL=C.UTF-8 add-apt-repository -y ppa:ondrej/php
apt-get update
# Install PHP
apt-get install -y php7.2\
php7.2-ldap \
php7.2-xml \
php7.2-xmlrpc \
php7.2-zip \
php7.2-mysql \
php7.2-mbstring \
php7.2-mcrypt \
php7.2-gd \
php7.2-readline \
php7.2-opcache \
php7.2-xdebug \
php7.2-dom \
php-xdebug \
php7.2-curl \
unzip
phpenmod xdebug
#Install composer
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php composer-setup.php ;
php -r "unlink('composer-setup.php');" ;
mv composer.phar /usr/local/bin/composer
build:
commands:
- echo Build started on `date`
- echo Installing composer deps
- composer install
post_build:
commands:
- echo Build completed on `date`
My laravel filesystem does not have the vendor folder as I would like it to be generated via composer install.
Would greatly appreciate a hand, i've tried so many things.. cant get it to generate properly.
I've also checked via ssh and the folder is not there grrr. Its like its being generated elsewhere.
Thanks!
Adding the following to my buildspec.yml enabled the vendor file to be uploaded to the working server.
artifacts:
files:
- '**/*'
proxy:
upload-artifacts: yes
logs: yes
Related
I try to install laravel 9 /mongodbsite under docker , based on
FROM php:8.1.6-apache
But running the app I got error:
Class "MongoDB\Driver\Manager" not found
Searching in net I found a possible decision as “php-mongo” package is not installed
But adding php-mongo in as :
RUN wget -qO - https://www.mongodb.org/static/pgp/server-6.0.asc | apt-key add -
RUN echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/6.0 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-6.0.list
...
RUN apt-get install -y mongodb-org php-mongo
I got error :
E: Package 'php-mongo' has no installation candidate
I tried to use php-mongodb-all-dev, php8.1-mongodb, but got similar errors.
Which package and have I to install ?
Updated Part 1:
I modified Dockerfile.yml as :
FROM php:8.1.6-apache
RUN apt-get update && \
apt-get install --assume-yes --no-install-recommends --quiet \
curl \
wget \
gnupg
RUN wget -qO - https://www.mongodb.org/static/pgp/server-6.0.asc | apt-key add -
RUN echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/6.0 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-6.0.list
ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
RUN chmod +x /usr/local/bin/install-php-extensions \
&& install-php-extensions mongo
RUN apt-get update && \
apt-get install --assume-yes --no-install-recommends --quiet \
python \
apt-transport-https \
libfreetype6-dev \
But I got error :
docker-compose up -d --build
...
Reading package lists...
### INSTALLING REQUIRED PACKAGES ###
# Packages to be kept after installation:
# Packages to be used only for installation: libsasl2-dev libssl-dev
debconf: delaying package configuration, since apt-utils is not installed
(Reading database ... 14467 files and directories currently installed.)
Preparing to unpack .../libssl1.1_1.1.1n-0+deb11u3_amd64.deb ...
Unpacking libssl1.1:amd64 (1.1.1n-0+deb11u3) over (1.1.1n-0+deb11u2) ...
Setting up libssl1.1:amd64 (1.1.1n-0+deb11u3) ...
Selecting previously unselected package libsasl2-dev.
(Reading database ... 14467 files and directories currently installed.)
Preparing to unpack .../libsasl2-dev_2.1.27+dfsg-2.1+deb11u1_amd64.deb ...
Unpacking libsasl2-dev (2.1.27+dfsg-2.1+deb11u1) ...
Selecting previously unselected package libssl-dev:amd64.
Preparing to unpack .../libssl-dev_1.1.1n-0+deb11u3_amd64.deb ...
Unpacking libssl-dev:amd64 (1.1.1n-0+deb11u3) ...
Setting up libsasl2-dev (2.1.27+dfsg-2.1+deb11u1) ...
Setting up libssl-dev:amd64 (1.1.1n-0+deb11u3) ...
Processing triggers for libc-bin (2.31-13+deb11u3) ...
### INSTALLING REMOTE MODULE mongo ###
WARNING: "pecl/mongo" is deprecated in favor of "channel:///mongodb"
pecl/mongo requires PHP (version >= 5.3.0, version <= 5.99.99), installed version is 8.1.6
No valid packages found
install failed
ERROR: Service 'web' failed to build: The command '/bin/sh -c chmod +x /usr/local/bin/install-php-extensions && install-php-extensions mongo' returned a non-zero code: 1
Which format of the command is valid ?
Thanks in advance!
php-mongo is a PHP extension and the default PHP images for docker do not allow installing PHP extensions on then using apt-get.
You can try doing the following in your Dockerfile instead:
ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
RUN chmod +x /usr/local/bin/install-php-extensions \
&& install-php-extensions mongodb
This is a more simplified approach than the official documentation.
More information on these images as well as the documentation to install extensions can be found in dockerhub
Information about docker-php-extension-installer can be found in Github
I am stuck with these errors for days and I have tried quite a couple of Dockerfile configurations.
Versions
PHP version: 7.3
Laravel version: ^6.2
Package version: ^3.1
Description
Exact errors
Problem 1
- Installation request for phpoffice/phpspreadsheet 1.11.0 -> satisfiable by phpoffice/phpspreadsheet[1.11.0].
- phpoffice/phpspreadsheet 1.11.0 requires ext-zip * -> the requested PHP extension zip is missing from your system.
Problem 2
- phpoffice/phpspreadsheet 1.11.0 requires ext-zip * -> the requested PHP extension zip is missing from your system.
- maatwebsite/excel 3.1.19 requires phpoffice/phpspreadsheet ^1.10 -> satisfiable by phpoffice/phpspreadsheet[1.11.0].
- Installation request for maatwebsite/excel 3.1.19 -> satisfiable by maatwebsite/excel[3.1.19].
To enable extensions, verify that they are enabled in your .ini files:
-
- /usr/local/etc/php/conf.d/docker-php-ext-bcmath.ini
- /usr/local/etc/php/conf.d/docker-php-ext-exif.ini
- /usr/local/etc/php/conf.d/docker-php-ext-gd.ini
- /usr/local/etc/php/conf.d/docker-php-ext-pcntl.ini
- /usr/local/etc/php/conf.d/docker-php-ext-pdo_mysql.ini
- /usr/local/etc/php/conf.d/docker-php-ext-sodium.ini
You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.
My Dockerfile
FROM php:7.3-fpm
# Arguments defined in docker-compose.yml
ARG user
ARG uid
# Install system dependencies
RUN apt-get update && apt-get install -y \
git \
curl \
libpng-dev \
libonig-dev \
libxml2-dev
RUN apt-get update && \
apt-get install -y \
libzip-dev \
&& docker-php-ext-install zip
# Clear cache
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
# Install PHP extensions
RUN docker-php-ext-install pdo_mysql mbstring exif pcntl bcmath gd
# Get latest Composer
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
# Create system user to run Composer and Artisan Commands
RUN useradd -G www-data,root -u $uid -d /home/$user $user
RUN mkdir -p /home/$user/.composer && \
chown -R $user:$user /home/$user
# Set working directory
WORKDIR /var/www
USER $user
# Run migration?
As I experienced, sometimes it is so confusing to install a php extension.
Fortunately there is an awesome repository(docker-php-extension-installer) for doing it painlessly:
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/bin/
RUN install-php-extensions zip
Also you can add any extensions without concerning about the dependencies.
I tried a number of solutions I found and none worked for me -- including this one. I had to resort to editing the php.ini inside of the docker container and specifying which extensions I wanted to use. I don't think it was a problem of extensions not being installed, but the php.ini was not being updated properly for some reason.
Here Is the article that helped me find php.ini
This was for the PHP:8.0.3-fpm-buster docker image.
Im fairly new to docker and so im trying to learn more about it using a laravel project, im following this tutorial:
https://www.digitalocean.com/community/tutorials/how-to-set-up-laravel-nginx-and-mysql-with-docker-compose
Ive adjusted the Dockerfile a bit from what the tutorial has but even the tutorial file causes the same result.
FROM php:7.3-fpm
# Copy composer.lock and composer.json
COPY composer.lock composer.json /var/www/
# Install dependencies
RUN curl -sL https://deb.nodesource.com/setup_10.x | bash - && \
apt-get update && apt-get install -y mysql-client \
RUN npm install -g npm
# Clear cache
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
# Install extensions
RUN docker-php-ext-install pdo pdo_mysql
# Install composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
# Add user for laravel application
RUN groupadd -g 1000 www
RUN useradd -u 1000 -ms /bin/bash -g www www
# Copy existing application directory contents
COPY . /var/www
# Copy existing application directory permissions
COPY --chown=www:www . /var/www
# Change current user to www
USER www
# Set working directory
WORKDIR /var/www
# Expose port 9000 and start php-fpm server
EXPOSE 9000
CMD ["php-fpm"]
But i keep getting the following error when i run docker-compose up -d:
E: Package 'mysql-client' has no installation candidate
ERROR: Service 'app' failed to build: The command '/bin/sh -c curl -sL https://deb.nodesource.com/setup_10.x | bash - && apt-get update && apt-get install -y mysql-client nodejs build-essential vim git curl' returned a non-zero code: 100
Am i missing something?
I expected this to work since i am running apt-get update before installing mysql-client.
Thanks.
php:7.3-fpm now use Debian 10 (Buster) as its base image and Buster ships with MariaDB, so just replace mysql-client with mariadb-client should fix it.
If you still want to use the mysql client, it's called default-mysql-client now.
php:7.2-apache triggers the error as well, but I resolve it using php:7.2.18-apache
it worked for me: sudo apt-get update && apt-get install -y git curl libmcrypt-dev default-mysql-client
or alternatively apt-cache search mysql-server
find out your servers then sudo apt-get install default-mysql-server default-mysql-server-core mariadb-server-10.6 mariadb-server-core-10.6
in my case it was the above codes
Project using docker php:7.1-fpm image to run my laravel application.
When installing laravel/cashier through prooph/composer:7.2, it throws an error:
Problem 1
- laravel/cashier v7.1.0 requires dompdf/dompdf ^0.8.0 -> satisfiable by dompdf/dompdf[v0.8.0, v0.8.1, v0.8.2].
- laravel/cashier v7.1.1 requires dompdf/dompdf ^0.8.0 -> satisfiable by dompdf/dompdf[v0.8.0, v0.8.1, v0.8.2].
- dompdf/dompdf v0.8.2 requires ext-gd * -> the requested PHP extension gd is missing from your system.
- dompdf/dompdf v0.8.1 requires ext-gd * -> the requested PHP extension gd is missing from your system.
- dompdf/dompdf v0.8.0 requires ext-gd * -> the requested PHP extension gd is missing from your system.
- Installation request for laravel/cashier ^7.1 -> satisfiable by laravel/cashier[v7.1.0, v7.1.1].
To enable extensions, verify that they are enabled in your .ini files:
- /usr/local/etc/php/php.ini
- /usr/local/etc/php/conf.d/amqp.ini
- /usr/local/etc/php/conf.d/docker-php-ext-bcmath.ini
- /usr/local/etc/php/conf.d/docker-php-ext-intl.ini
- /usr/local/etc/php/conf.d/docker-php-ext-pcntl.ini
- /usr/local/etc/php/conf.d/docker-php-ext-pdo_mysql.ini
- /usr/local/etc/php/conf.d/docker-php-ext-pdo_pgsql.ini
- /usr/local/etc/php/conf.d/docker-php-ext-soap.ini
- /usr/local/etc/php/conf.d/docker-php-ext-zip.ini
- /usr/local/etc/php/conf.d/mongodb.ini
- /usr/local/etc/php/conf.d/php7.ini
- /usr/local/etc/php/conf.d/redis.ini
- /usr/local/etc/php/conf.d/zmq.ini
You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.
Installation failed, reverting ./composer.json to its original content.
Here is my dockerfile content:
FROM php:7.1-fpm
RUN echo "deb http://www.deb-multimedia.org jessie main" >> /etc/apt/sources.list &&\
curl -L http://www.deb-multimedia.org/pool/main/d/deb-multimedia-keyring/deb-multimedia-keyring_2016.8.1_all.deb -o /deb-multimedia-keyring.deb &&\
dpkg -i /deb-multimedia-keyring.deb
RUN apt-get update && apt-get install -y \
libfreetype6-dev libjpeg62-turbo-dev libmcrypt-dev libpng-dev cron libcurl3 imagemagick libav-tools python
RUN docker-php-ext-configure mcrypt && \
docker-php-ext-install -j$(nproc) iconv mcrypt pdo_mysql opcache && \
docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ && \
docker-php-ext-install -j$(nproc) gd
RUN echo "* * * * * root php /var/www/tidytide/artisan schedule:run &> /var/log/cron.artisan" >> /etc/crontab
WORKDIR /var/www/tidytide
COPY --chown=www-data:www-data . .
COPY ./entrypoint.sh /
ENTRYPOINT /entrypoint.sh
The problem is that cashier requires dompdf package, which requires gd library enabled on php. GD library is installed through dockerfile, and as I see that dompdf doesn't observe this.
If you're using different container (and different PHP version) for composer installation, you should probably use platform settings in your composer.json to mimic configuration of container where you actually run your app:
"config": {
"platform": {
"php": "7.1",
"ext-gd": "*"
}
},
Composer will act like you're using PHP 7.1 with GD extension enabled, even if your actually using PHP 7.2 without this extension for running Composer.
I'm running the following commands in Travis CI for my build:
before_install:
- curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer
script:
- sudo composer -nqq update
I'm installing composer manually as I want to use sudo with it, as it's installed only for the user.
The error which I'm having are:
Updating dependencies (including require-dev)
- Installing jakub-onderka/php-console-color (0.1)
Downloading: Connecting... Failed to download jakub-onderka/php-console-color from dist: The "https://api.github.com/repos/JakubOnderka/PHP-Console-Color/zipball/e0b393dacf7703fc36a4efc3df1435485197e6c1" file could not be downloaded (HTTP/1.1 403 Forbidden)
Now trying to download from source
- Installing symfony/yaml (v2.7.4)
Downloading: Connecting... Failed to download symfony/yaml from dist: The "https://api.github.com/repos/symfony/Yaml/zipball/2dc7b06c065df96cc686c66da2705e5e18aef661" file could not be downloaded (HTTP/1.1 403 Forbidden)
Now trying to download from source
I've tried these links and they work fine.
Does it mean Travis is blocking GitHub API for some reason? If not, how do I fix it?
By fix, I mean either to know what's going on, or suppress these error messages (e.g. by using some special parameter in composer or changes to JSON file to force downloads from the source).
My composer.json file is:
{
"config": {
"vendor-dir": "/var/lib/vendor",
"bin-dir": "/usr/local/bin"
},
"require": {
"drush/drush": "dev-master"
}
}
For the reference, the full .travis.yml looks like:
before_install:
- env
- curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer
- sudo apt-get -qy update
install:
- sudo apt-get install vagrant
script:
- set -e # This makes build to fail on first error.
- sudo composer -nqq update
- make
- make vm
after_failure:
- sudo apt-get -qy install tree && - tree -d -L 6 # Print directory structure in the form of a tree.
- env
sudo: true
language: php
python:
- "5.5"
Most probable reason for the error is limited amount of downloads from github. What you need to do is create a token in your github account and add it globally to your composer with
composer config -g github-oauth.github.com <your-token>
Source: https://getcomposer.org/doc/articles/troubleshooting.md#api-rate-limit-and-oauth-tokens
My suggestions are:
Remove:
curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer
sudo composer -nqq update
First line: not needed, because Composer is pre-installed, when you use language: php.
Second line: its better to execute composer install, because update uses the data from composer.lock if your repo contains one. And sudo is not needed here.
(Sidenote on the usage of sudo on Travis-CI:
sudo is only available in the non-containainer based infrastructure. I don't know if you really need this, but maybe you could switch to the faster container based infrastrucutre by setting sudo: false in your travis.yml, see http://docs.travis-ci.com/user/workers/container-based-infrastructure/ . Just a hint.)
Add to travis.yml
before_install:
- composer self-update
- composer install --no-interaction --optimize-autoloader
First line: update the (possibly) outdated composer of this Travis instance.
Second line: install dependencies described in composer.json with Composer.
The additional parameters to switch between downloading "Dist" or downloading "Source" are --prefer-dist and --prefer-source.
So its either
- composer install --prefer-dist --no-interaction --optimize-autoloader
or
- composer install --prefer-source --no-interaction --optimize-autoloader
Does it mean Travis is blocking GitHub API for some reason?
If its not a temporary issue, then its seems your Composer is running into the Github API rate-limit. The GitHub API allows only a low number of requests for unauthenticated users. You can raise the API limit by authenticating at Github from Travis.
See FAQ: https://getcomposer.org/doc/articles/troubleshooting.md#api-rate-limit-and-oauth-tokens
Please try it with prefer-source first.