I am trying to install Drupal 8.5.0 via composer, using drupal-composer/drupal-project.
My OS is windows and I have run the command on "Command Prompt"
composer create-project drupal-composer/drupal-project:8.x-dev some-dir --stability dev --no-interaction
After run this command I got drupal 8.7.4.
But I want to install drupal 8.5.0 via composer for some demo purpose.
Please suggest me. Thanks!
The command you tried to run will download the latest dev version of the project. If you want to modify versions, or anything that comes along with the project, you can do so by adding the --no-install flag to your command:
composer create-project drupal-composer/drupal-project:8.x-dev some-dir --stability dev --no-interaction --no-install
This will download the files, but won't run composer install. Now you can edit the composer.json file to change the desired version of the drupal/core package.
But sadly whis will make conflicts with the webflo/drupal-core-require-dev package which only accepts higher core version than 8.7.0 - so you need to change that line as well to the desired version.
So, the require and require-dev section of the composer.json looks like this:
"require": {
"php": ">=5.6",
"composer/installers": "^1.2",
"cweagans/composer-patches": "^1.6.5",
"drupal-composer/drupal-scaffold": "^2.5",
"drupal/console": "^1.0.2",
"drupal/core": "8.5.0",
"drush/drush": "^9.0.0",
"vlucas/phpdotenv": "^2.4",
"webflo/drupal-finder": "^1.0.0",
"webmozart/path-util": "^2.3",
"zaporylie/composer-drupal-optimizations": "^1.0"
},
"require-dev": {
"webflo/drupal-core-require-dev": "8.5.0"
},
After changing the lines, all you need to do is run the command:
composer install
Also check out this thread on drupal.org
Related
This is similar to an unanswered question from a year ago. Supposedly I have an update for drupal/core:
$ composer outdated "drupal/*"
drupal/core 8.6.10 8.6.12 Drupal is an open source content ...
But when I run update ...
$ composer update drupal/core --with-dependencies
Dependency "asm89/stack-cors" is also a root requirement, but is not explicitly whitelisted. Ignoring.
Dependency "composer/semver" is also a root requirement, but is not explicitly whitelisted. Ignoring.
[ ... ]
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Package phpunit/phpunit-mock-objects is abandoned, you should avoid using it. No replacement was suggested.
Generating autoload files
> Drupal\Core\Composer\Composer::preAutoloadDump
> Drupal\Core\Composer\Composer::ensureHtaccess
I'm trying to follow the instructions to update drupal 8 via composer found here: https://www.drupal.org/docs/8/update/update-core-via-composer
I had the same issue today with updating Drupal and the following process helped me solve the issue.
Run the composer update command using the specific version you are trying to update to. In this instance it would be composer require drupal/core:8.6.12 --update-with-dependencies If there is an issue blocking the update this should show you a list of problems. in my case I tried to update to version 8.6.11 and it output the following.
Problem 1
. Installation request for drupal/core 8.6.11 -> satisfiable by
drupal/core[8.6.11].
. Can only install one of: twig/twig[1.x-dev, v1.35.3].
. Can only install one of: twig/twig[v1.35.3, 1.x-dev].
. Can only install one of: twig/twig[1.x-dev, v1.35.3].
. drupal/core 8.6.11 requires twig/twig ^1.38.2 -> satisfiable by
twig/twig[1.x-dev, v1.38.2].
. Conclusion: don't install twig/twig v1.38.2
. Installation request for twig/twig (locked at v1.35.3, required as
^1.35.0) -> satisfiable by twig/twig[v1.35.3].
If there is no problem listed try clearing the composer cache composer clearcache and then try the update command again.
you can also try running the why-not composer command to see if that highlights any issues composer why-not drupal/core:8.6.12
In my case the issue was that the twig component required for 8.6.12 was v1.38.2 but was capped at a lower version 1.35 in the composer file. I used the following command to update the twig version and that allowed me to update to Drupal 8.6.12 using my normal update process.
composer require twig/twig:1.35.2
I hope this helps.
Drupal 8 is notoriously slow on the first page (like the install page) or the front page after a webserver starts up (including under ddev). Is there a way I can speed it up a bit? I think the problem is that all those thousands of Drupal php files have to be loaded into the opcache before it runs right. Is there a way to do that?
I'm experimenting with the brand new Composer-Preload package for this. It's fairly easy to get going with Drupal 8. The maintainer has been super responsive in improving it for compatibility with Drupal.
As suggested in the README:
composer require ayesh/composer-preload (or ddev composer require ayesh/composer-preload
Edit the composer.json to add the required section to "extra":
"preload": {
"paths": [
"web"
],
"exclude": [
"web/core/tests",
"web/core/lib/Drupal/Component/Assertion",
"web/core/modules/simpletest",
"web/core/modules/editor/src/Tests"
],
"no-status-check": false
}
run composer preload (or ddev composer preload). This creates the vendor/preload.php that does the actual preloading. It rummages through all the files in the listed directories to see what should be preloaded.
Link the preload.php into your docroot (or another directory reachable from the webserver). For example, is the docroot is "web", inside the web container (ddev ssh) do ln -s /var/www/html/vendor/preload.php /var/www/html/web/preload.php
If for ddev, add a curl command to run on ddev start in your .ddev/config.yaml:
hooks:
post-start:
- exec: curl -s localhost/preload.php
Your mileage may vary, but it seemed to me that my D8 project was much snappier to start with this setup. Thanks to #ayesh for the excellent Composer-Preload project, it has a great future.
Our solution has been to use APCu, which I recommend in production as well. Here's how we have DDEV setup -- also, I recommend disabling the Symfony APCClassLoader as it's deprecated and slower.
ddev/config.yaml
hooks:
post-start:
- exec: sudo apt-get update
- exec: sudo apt-get install -y php-apcu
your settings.php
// Don't use Symfony's APCLoader. Composer's APCu loader has better performance.
$settings['class_loader_auto_detect'] = FALSE;
I'm following this guide to "Update core via Composer" and I have my backups. The document says to run
composer update drupal/core --with-dependencies
When I do, I get:
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Generating autoload files
> Drupal\Core\Composer\Composer::preAutoloadDump
> Drupal\Core\Composer\Composer::ensureHtaccess
drush core-status says I'm on version 8.4.3, so I expected the composer update command to move me to 8.4.5.
Later the document says to "Review the status report page for errors" and the only error listed is that I need to be on version 8.4.5
There must be something missing from the update documentation, and I can't figure out what it is.
Edit: Thanks Robb Davis, I tried:
rm -rf vendor
rm composer.lock
composer update drupal/core --with-dependencies
That gave me no change -- leaving me with an 8.4.3 installation.
I tried composer require drupal/core:8.5 which gave me:
$ composer require drupal/core:8.5
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for drupal/drupal dev-master -> satisfiable by drupal/drupal[dev-master].
- don't install drupal/core 8.5.0|remove drupal/drupal dev-master
- Installation request for drupal/core 8.5 -> satisfiable by drupal/core[8.5.0].
Installation failed, reverting ./composer.json to its original content.
Nothing in that message makes any sense to me. So I'm still lost.
I was trying to update 8.5 to 8.6. Dumping the core and vendor folders in addition to the composer.lock file did not work for me.
I was able to resolve this issue by removing the core/composer.json line from the merge-plugin include array and running composer update drupal/core --with-dependencies.
My merge-plugin key in the composer.json file in the docroot looks like:
"merge-plugin": {
"include": [],
"recurse": true,
"replace": false,
"merge-extra": false
}
yes this is kind of foobar. There is a blog post about it here:
https://orkjern.com/updating-to-drupal-85-with-composer
The solution in the blog didn't work for me but a solution in the comments did:
Delete your vendors directory
Delete your .lock file
Run composer update drupal/core --with-dependencies
This will rebuild / redownload everything but it seems to work and updates properly to 8.5 (the most recent stable version of core).
I have a number of environments running in AWS Elastic Beanstalk. I deploy direct from git using git aws.push.
I use composer.json to install required php sdk's. I've not changed this file for a long time but it's suddenly started failing in all environments.
Output from the AWS logs is
+ echo 'Found composer.json file. Attempting to install vendors.'
Found composer.json file. Attempting to install vendors.
+ composer.phar install --no-ansi --no-interaction
Loading composer repositories with package information
Installing dependencies
[RuntimeException]
Could not load package aws/aws-sdk-php in http://packagist.org: [UnexpectedValueException] Could not parse version constraint ^5.3: Invalid version string "^5.3"
[UnexpectedValueException]
Could not parse version constraint ^5.3: Invalid version string "^5.3"
install [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--no-custom-installers] [--no-scripts] [--no-progress] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader]
2015-05-28 09:57:18,414 [ERROR] (15056 MainThread) [directoryHooksExecutor.py-33] [root directoryHooksExecutor error] Script /opt/elasticbeanstalk/hooks/appdeploy/pre/10_composer_install.sh failed with returncode 1
my composer.json is:
{
"require": {
"aws/aws-sdk-php": "2.7.*",
"monolog/monolog": "1.0.*",
"facebook/php-sdk-v4" : "4.0.*",
"ext-curl": "*",
"paypal/sdk-core-php": "v1.4.2",
"paypal/permissions-sdk-php":"v2.5.106",
"paypal/adaptivepayments-sdk-php":"2.*"
}
}
I notice it does want the aws-sdk-php but the version is not 5.3 (which is mentioned in the logs).
5.3 makes me think php version, checking php -v i get
php -v
PHP 5.5.12 (cli) (built: May 20 2014 22:27:36)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
with Zend OPcache v7.0.4-dev, Copyright (c) 1999-2014, by Zend Technologies
I've tried re-installing older versions that have previously installed fine and they also fail with the same error. This has to be due to the environment. Does anyone know if there have been changes recently.
Create a folder in your root of the project called .ebextensions. Then create a new file in there called 01-composer-install.config with the following content.
commands:
01_update_composer:
command: export COMPOSER_HOME=/root && /usr/bin/composer.phar self-update
option_settings:
- namespace: aws:elasticbeanstalk:application:environment
option_name: COMPOSER_HOME
value: /root
I just had to update composer using the instructions here:
https://getcomposer.org/download/
Environment: MAC - Mountain Lion
I am trying to use the AWS PHP SDK for a project. I followed the Amazon web site's SDK installation directions (through composer) -- using the following Link to AWS
I created the file compser.json. Contens:
{
"require": {
"aws/aws-sdk-php": "2.*"
}
}
From the command line, I typed:
curl -s "http://getcomposer.org/installer" | php
Then
php composer.phar install
A new directory appeared "vendor" and inside it, the AWS SDK 2 was automatically installed.
The problem is that I am expecting (per the code example I'm trying to follow), I am expecting to see the following file:
vendor/aws/aws-sdk-for-php/sdk.class.php
But it's not there. Could this be referencing an older version of the SDK?
The automatically generated by the "php composer.phar install" command: vendor/autoload.php looks like this:
<?php
// autoload.php generated by Composer
require_once __DIR__ . '/composer' . '/autoload_real.php';
return ComposerAutoloaderInit25a7292f83dd9a43a459f6c2e51befba::getLoader();
Is it possible that the file: sdk.class.php is valid for version 1 of the SDK, but not version 2?
Entirely correct. sdk.class.php is a file that exists in SDK 1.x, but not 2.x.
The correct instructions are in the SDK2 README.