aspendigital / docker-octobercms

Dockerized October CMS: PHP, Composer, October core and dependencies
MIT License
150 stars 54 forks source link

Error with php7.2-apache image in composer autoloading #16

Closed wodka closed 5 years ago

wodka commented 5 years ago

Right now when I start the image it cannot load certain files.

PHP Fatal error: Class Illuminate\\Database\\Eloquent\\Collection contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (Illuminate\\Contracts\\Queue\\QueueableCollection::getQueueableRelations) in /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Collection.php on line 11

this error is caused by the following read error:

PHP Fatal error: Uncaught Error: Class 'October\\Rain\\Database\\Collection' not found in /var/www/html/vendor/october/rain/src/Database/Model.php:608
Stack trace:
#0 /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(261): October\\Rain\\Database\\Model->newCollection(Array)
#1 /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(1477): Illuminate\\Database\\Eloquent\\Builder->hydrate(Array)
#2 /var/www/html/vendor/october/rain/src/Extension/ExtendableTrait.php(411): Illuminate\\Database\\Eloquent\\Model->__call('hydrate', Array)
#3 /var/www/html/vendor/october/rain/src/Database/Model.php(635): October\\Rain\\Database\\Model->extendableCall('hydrate', Array)
#4 /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(481): October\\Rain\\Database\\Model->__call('hydrate', Array)
#5 /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(465): Illuminate\\Database\\Eloquent\\Builder->getModels(Array)
#6 /var/www/html/vendor/laravel in /var/www/html/vendor/october/rain/src/Database/Model.php on line 608

I can get it to work if I simply run composer install -o once inside the container - which indicates to me that the composer autoloading seems to be broken in some way

petehalverson commented 5 years ago

@wodka I'm not able to recreate the issue you're describing. Can you provide a bit more information?

Perhaps the command you're using to start the container or a docker-compose.yml?

Since the /vendor folder is baked into the image, I'm guessing it's been overwritten somehow. Do you have any volumes mounted? Are you replacing any files on start?

wodka commented 5 years ago

I use the image in Amazon ECS - there I'm mounting 3 volumes:

app -> /var/www/html/storage/app plugins -> /var/www/html/plugins themes -> /var/www/html/themes

the plugins folder contains 2 plugins - one with an additional Vendor folder (I'm not sure if that is connected to the problem)

right now I use the following Dockerfile for it to work on ecs:

FROM aspendigital/octobercms:php7.2-apache

RUN composer install -o
petehalverson commented 5 years ago

Yeah, I'm curious if it's just the plugin missing some vendor code. I added a flag for the entrypoint script to trigger a composer install at startup within plugin folders.

Try using ENV INIT_PLUGINS=true instead.

true runs composer install in plugins folders where no 'vendor' folder exists. force runs composer install regardless. Helpful when using git submodules for plugins.

Here's some info regarding the environment variables which trigger actions run by the entrypoint script at runtime.

wodka commented 5 years ago

This is sadly something I already tried (with true and force) - running composer install inside each of the plugins does not make a difference.

Only running it on /var/www/html works :/

petehalverson commented 5 years ago

Hmm. Can you provide the verbose output from the composer install RUN composer install -vvv -o?

wodka commented 5 years ago

here it is the full output of the docker build with RUN composer install -vvv -o

show output

``` Sending build context to Docker daemon 6.656kB Step 1/3 : FROM aspendigital/octobercms:php7.2-apache ---> ce00ca0b68f4 Step 2/3 : RUN apt-get update && apt-get install -y libxml2-dev && docker-php-ext-install xmlrpc ---> Using cache ---> e2152647b058 Step 3/3 : RUN composer install -vvv -o ---> Running in 4ba7cde87ca9 Reading ./composer.json Loading config file ./composer.json Checked CA file /etc/ssl/certs/ca-certificates.crt: valid Executing command (/var/www/html): git branch --no-color --no-abbrev -v Executing command (/var/www/html): git describe --exact-match --tags Executing command (/var/www/html): git log --pretty="%H" -n1 HEAD Executing command (/var/www/html): hg branch Executing command (/var/www/html): fossil branch list Executing command (/var/www/html): fossil tag list Executing command (/var/www/html): svn info --xml Reading /root/.composer/composer.json Loading config file /root/.composer/composer.json Reading /var/www/html/vendor/composer/installed.json Reading /root/.composer/vendor/composer/installed.json Loading plugin Composer\Installers\Plugin Loading plugin Wikimedia\Composer\MergePlugin Loading plugin Hirak\Prestissimo\Plugin [merge-plugin] Loading plugins/october/demo/composer.json... [merge-plugin] Deferring duplicate php [merge-plugin] Merging composer/installers Running 1.8.0 (2018-12-03 10:31:16) with PHP 7.2.14 on Linux / 4.9.125-linuxkit Reading ./composer.lock [merge-plugin] Already merged plugins/october/demo/composer.json completely Loading composer repositories with package information Installing dependencies (including require-dev) from lock file Reading ./composer.lock [merge-plugin] Adding dependency october/demo-plugin requires php (>= 5.4.0.0-dev) Resolving dependencies through SAT Looking at all rules. Dependency resolution completed in 0.003 seconds Analyzed 216 packages to resolve dependencies Analyzed 662 rules to resolve dependencies Nothing to install or update Generating optimized autoload files [merge-plugin] Already merged plugins/october/demo/composer.json completely Removing intermediate container 4ba7cde87ca9 ---> 88a5f0fc1fef Successfully built 88a5f0fc1fef ```

petehalverson commented 5 years ago

Thanks. Can you share the composer.lock from that plugin with a vendor folder?

wodka commented 5 years ago

yes, here it is the content of the composer.lock file of the one plugin:

show content

``` { "_readme": [ "This file locks the dependencies of your project to a known state", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], "content-hash": "fe1293f13b7ba7df4ec89135f7976666", "packages": [ { "name": "doctrine/inflector", "version": "v1.3.0", "source": { "type": "git", "url": "https://github.com/doctrine/inflector.git", "reference": "5527a48b7313d15261292c149e55e26eae771b0a" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/doctrine/inflector/zipball/5527a48b7313d15261292c149e55e26eae771b0a", "reference": "5527a48b7313d15261292c149e55e26eae771b0a", "shasum": "" }, "require": { "php": "^7.1" }, "require-dev": { "phpunit/phpunit": "^6.2" }, "type": "library", "extra": { "branch-alias": { "dev-master": "1.3.x-dev" } }, "autoload": { "psr-4": { "Doctrine\\Common\\Inflector\\": "lib/Doctrine/Common/Inflector" } }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], "authors": [ { "name": "Roman Borschel", "email": "roman@code-factory.org" }, { "name": "Benjamin Eberlei", "email": "kontakt@beberlei.de" }, { "name": "Guilherme Blanco", "email": "guilhermeblanco@gmail.com" }, { "name": "Jonathan Wage", "email": "jonwage@gmail.com" }, { "name": "Johannes Schmitt", "email": "schmittjoh@gmail.com" } ], "description": "Common String Manipulations with regard to casing and singular/plural rules.", "homepage": "http://www.doctrine-project.org", "keywords": [ "inflection", "pluralize", "singularize", "string" ], "time": "2018-01-09T20:05:19+00:00" }, { "name": "edujugon/laradoo", "version": "1.1.1", "source": { "type": "git", "url": "https://github.com/Edujugon/laradoo.git", "reference": "e4fdb52a8c25fc84294428a72607db2f1c236af1" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/Edujugon/laradoo/zipball/e4fdb52a8c25fc84294428a72607db2f1c236af1", "reference": "e4fdb52a8c25fc84294428a72607db2f1c236af1", "shasum": "" }, "require": { "illuminate/support": "^5.1" }, "require-dev": { "phpunit/phpunit": "~4.8" }, "type": "library", "autoload": { "psr-4": { "Edujugon\\Laradoo\\": "src/" }, "files": [ "src/Support/helpers.php" ], "classmap": [ "src/ripcord" ] }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], "authors": [ { "name": "Eduardo Marcos", "email": "edujugon@gmail.com" } ], "description": "Odoo ERP API for Laravel", "keywords": [ "ERP", "laravel", "odoo", "package" ], "time": "2017-06-04T15:41:57+00:00" }, { "name": "illuminate/contracts", "version": "v5.6.16", "source": { "type": "git", "url": "https://github.com/illuminate/contracts.git", "reference": "322ec80498b3bf85bc4025d028e130a9b50242b9" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/illuminate/contracts/zipball/322ec80498b3bf85bc4025d028e130a9b50242b9", "reference": "322ec80498b3bf85bc4025d028e130a9b50242b9", "shasum": "" }, "require": { "php": "^7.1.3", "psr/container": "~1.0", "psr/simple-cache": "~1.0" }, "type": "library", "extra": { "branch-alias": { "dev-master": "5.6-dev" } }, "autoload": { "psr-4": { "Illuminate\\Contracts\\": "" } }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], "authors": [ { "name": "Taylor Otwell", "email": "taylor@laravel.com" } ], "description": "The Illuminate Contracts package.", "homepage": "https://laravel.com", "time": "2018-04-07T17:05:26+00:00" }, { "name": "illuminate/support", "version": "v5.6.16", "source": { "type": "git", "url": "https://github.com/illuminate/support.git", "reference": "fad0669f858423679497a17f973261cc32f9a5a8" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/illuminate/support/zipball/fad0669f858423679497a17f973261cc32f9a5a8", "reference": "fad0669f858423679497a17f973261cc32f9a5a8", "shasum": "" }, "require": { "doctrine/inflector": "~1.1", "ext-mbstring": "*", "illuminate/contracts": "5.6.*", "nesbot/carbon": "^1.24.1", "php": "^7.1.3" }, "conflict": { "tightenco/collect": "<5.5.33" }, "suggest": { "illuminate/filesystem": "Required to use the composer class (5.6.*).", "symfony/process": "Required to use the composer class (~4.0).", "symfony/var-dumper": "Required to use the dd function (~4.0)." }, "type": "library", "extra": { "branch-alias": { "dev-master": "5.6-dev" } }, "autoload": { "psr-4": { "Illuminate\\Support\\": "" }, "files": [ "helpers.php" ] }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], "authors": [ { "name": "Taylor Otwell", "email": "taylor@laravel.com" } ], "description": "The Illuminate Support package.", "homepage": "https://laravel.com", "time": "2018-04-05T21:19:22+00:00" }, { "name": "nesbot/carbon", "version": "1.25.0", "source": { "type": "git", "url": "https://github.com/briannesbitt/Carbon.git", "reference": "cbcf13da0b531767e39eb86e9687f5deba9857b4" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/cbcf13da0b531767e39eb86e9687f5deba9857b4", "reference": "cbcf13da0b531767e39eb86e9687f5deba9857b4", "shasum": "" }, "require": { "php": ">=5.3.9", "symfony/translation": "~2.6 || ~3.0 || ~4.0" }, "require-dev": { "friendsofphp/php-cs-fixer": "~2", "phpunit/phpunit": "^4.8.35 || ^5.7" }, "type": "library", "extra": { "branch-alias": { "dev-master": "1.23-dev" } }, "autoload": { "psr-4": { "Carbon\\": "src/Carbon/" } }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], "authors": [ { "name": "Brian Nesbitt", "email": "brian@nesbot.com", "homepage": "http://nesbot.com" } ], "description": "A simple API extension for DateTime.", "homepage": "http://carbon.nesbot.com", "keywords": [ "date", "datetime", "time" ], "time": "2018-03-19T15:50:49+00:00" }, { "name": "psr/container", "version": "1.0.0", "source": { "type": "git", "url": "https://github.com/php-fig/container.git", "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/php-fig/container/zipball/b7ce3b176482dbbc1245ebf52b181af44c2cf55f", "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f", "shasum": "" }, "require": { "php": ">=5.3.0" }, "type": "library", "extra": { "branch-alias": { "dev-master": "1.0.x-dev" } }, "autoload": { "psr-4": { "Psr\\Container\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], "authors": [ { "name": "PHP-FIG", "homepage": "http://www.php-fig.org/" } ], "description": "Common Container Interface (PHP FIG PSR-11)", "homepage": "https://github.com/php-fig/container", "keywords": [ "PSR-11", "container", "container-interface", "container-interop", "psr" ], "time": "2017-02-14T16:28:37+00:00" }, { "name": "psr/simple-cache", "version": "1.0.1", "source": { "type": "git", "url": "https://github.com/php-fig/simple-cache.git", "reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/php-fig/simple-cache/zipball/408d5eafb83c57f6365a3ca330ff23aa4a5fa39b", "reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b", "shasum": "" }, "require": { "php": ">=5.3.0" }, "type": "library", "extra": { "branch-alias": { "dev-master": "1.0.x-dev" } }, "autoload": { "psr-4": { "Psr\\SimpleCache\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], "authors": [ { "name": "PHP-FIG", "homepage": "http://www.php-fig.org/" } ], "description": "Common interfaces for simple caching", "keywords": [ "cache", "caching", "psr", "psr-16", "simple-cache" ], "time": "2017-10-23T01:57:42+00:00" }, { "name": "symfony/polyfill-mbstring", "version": "v1.7.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", "reference": "78be803ce01e55d3491c1397cf1c64beb9c1b63b" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/78be803ce01e55d3491c1397cf1c64beb9c1b63b", "reference": "78be803ce01e55d3491c1397cf1c64beb9c1b63b", "shasum": "" }, "require": { "php": ">=5.3.3" }, "suggest": { "ext-mbstring": "For best performance" }, "type": "library", "extra": { "branch-alias": { "dev-master": "1.7-dev" } }, "autoload": { "psr-4": { "Symfony\\Polyfill\\Mbstring\\": "" }, "files": [ "bootstrap.php" ] }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], "authors": [ { "name": "Nicolas Grekas", "email": "p@tchwork.com" }, { "name": "Symfony Community", "homepage": "https://symfony.com/contributors" } ], "description": "Symfony polyfill for the Mbstring extension", "homepage": "https://symfony.com", "keywords": [ "compatibility", "mbstring", "polyfill", "portable", "shim" ], "time": "2018-01-30T19:27:44+00:00" }, { "name": "symfony/translation", "version": "v4.0.8", "source": { "type": "git", "url": "https://github.com/symfony/translation.git", "reference": "e20a9b7f9f62cb33a11638b345c248e7d510c938" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/symfony/translation/zipball/e20a9b7f9f62cb33a11638b345c248e7d510c938", "reference": "e20a9b7f9f62cb33a11638b345c248e7d510c938", "shasum": "" }, "require": { "php": "^7.1.3", "symfony/polyfill-mbstring": "~1.0" }, "conflict": { "symfony/config": "<3.4", "symfony/dependency-injection": "<3.4", "symfony/yaml": "<3.4" }, "require-dev": { "psr/log": "~1.0", "symfony/config": "~3.4|~4.0", "symfony/dependency-injection": "~3.4|~4.0", "symfony/finder": "~2.8|~3.0|~4.0", "symfony/intl": "~3.4|~4.0", "symfony/yaml": "~3.4|~4.0" }, "suggest": { "psr/log": "To use logging capability in translator", "symfony/config": "", "symfony/yaml": "" }, "type": "library", "extra": { "branch-alias": { "dev-master": "4.0-dev" } }, "autoload": { "psr-4": { "Symfony\\Component\\Translation\\": "" }, "exclude-from-classmap": [ "/Tests/" ] }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], "authors": [ { "name": "Fabien Potencier", "email": "fabien@symfony.com" }, { "name": "Symfony Community", "homepage": "https://symfony.com/contributors" } ], "description": "Symfony Translation Component", "homepage": "https://symfony.com", "time": "2018-02-22T10:50:29+00:00" } ], "packages-dev": [], "aliases": [], "minimum-stability": "stable", "stability-flags": [], "prefer-stable": false, "prefer-lowest": false, "platform": [], "platform-dev": [] } ```

jimcottrell commented 5 years ago

@wodka According to the composer.lock you posted, for your plugin you're getting v5.6 of illuminate/contracts, which defines QueueableCollection::getQueueableRelations from your posted error message. OctoberCMS is written against Laravel v5.5 though, which does not have that function in the QueueableCollection contract. If running composer install on image build is correcting your issue, I assume you must be ending up with a 5.5 version autoloading and your plugin's dependency code never loaded, but the real fix would be to ensure that your plugin defines dependencies compatible with October.

wodka commented 5 years ago

@jimcottrell thank you - did not realize that