GithubHelp home page GithubHelp logo

drupal-composer / drupal-project Goto Github PK

View Code? Open in Web Editor NEW
1.6K 99.0 943.0 338 KB

:rocket: Composer template for Drupal projects. Quick installation via "composer create-project drupal-composer/drupal-project"

License: GNU General Public License v2.0

PHP 100.00%
drupal composer

drupal-project's Introduction

Composer template for Drupal projects

CI LICENSE

This project template provides a starter kit for managing your site dependencies with Composer.

Important

Drupal 11 branch is available!

What does the template do?

  • Drupal will be installed in the web directory.
  • Generated composer autoloader vendor/autoload.php is used instead of web/vendor/autoload.php provided by Drupal core.
  • Modules (packages of type drupal-module) will be placed in web/modules/contrib directory.
  • Themes (packages of type drupal-theme) will be placed in web/themes/contrib directory.
  • Profiles (packages of type drupal-profile) will be placed in web/profiles/contrib directory.
  • Creates default writable versions of settings.php and services.yml.
  • Creates web/sites/default/files directory.
  • Drush is installed for use as vendor/bin/drush.
  • Provides an example of the .env file.

Installing

Note

The instructions below refer to the global Composer installation. You might need to replace composer with php composer.phar (or similar) for your setup.

Create your project:

composer create-project drupal-composer/drupal-project:10.x-dev some-dir --no-interaction

The composer create-project command passes ownership of all files to the project that is created. You should create a new Git repository, and commit all files not excluded by the .gitignore file.

Usage

Adding new dependencies

Use composer require to include and download dependencies for your project.

cd some-dir
composer require drupal/devel

By default, this project is set to install only stable releases of dependencies, as specified by "minimum-stability": "stable" in composer.json. If you need to use non-stable releases (e.g., alpha, beta, RC), you can modify the version constraint to allow for such versions. For instance, to require a beta version of a module:

composer require drupal/devel:1.0.0-beta1

Alternatively, you can globally adjust the stability settings by modifying composer.json to include the desired stability level and explicitly allow it:

{
    "minimum-stability": "beta",
    "prefer-stable": true
}

This configuration ensures that stable releases are preferred, but allows the installation of non-stable packages when necessary.

Adding libraries

You can manage front-end asset libraries with Composer thanks to the asset-packagist repository. Composer will detect and install new versions of a library that meet the stated constraints.

composer require bower-asset/dropzone

Custom installation paths for libraries

The installation path of a specific library can be controlled by adding it to the extra.installer-paths configuration preceding web/libraries/{$name}. For example, the chosen Drupal module expects the chosen library to be located on web/libraries/chosen, but composer require npm-asset/chosen-js installs the library into web/libraries/chosen-js. The following configuration overrides installation it into the expected directory:

{
    "extra": {
        "installer-paths": {
            "web/libraries/chosen": [
                "npm-asset/chosen-js"
            ],
            "web/libraries/{$name}": [
                "type:drupal-library",
                "type:npm-asset",
                "type:bower-asset"
            ]
        }
    }
}

For more details, see https://asset-packagist.org/site/about

Updating Drupal Core

This project will attempt to keep all of your Drupal Core files up-to-date; the project drupal/core-composer-scaffold is used to ensure that your scaffold files are updated every time drupal/core is updated.

If you customize any of the "scaffolding" files (commonly .htaccess), you may need to merge conflicts if any of your modified files are updated in a new release of Drupal core.

Follow the steps below to update your Drupal core files.

  1. Run composer update "drupal/core-*" --with-dependencies to update Drupal Core and its dependencies.
  2. Run git diff to determine if any of the scaffolding files have changed. Review the files for any changes and restore any customizations to .htaccess or robots.txt.
  3. Commit everything all together in a single commit, so web will remain in sync with the core when checking out branches or running git bisect.
  4. In the event that there are non-trivial conflicts in step 2, you may wish to perform these steps on a branch, and use git merge to combine the updated core files with your customized files. This facilitates the use of a three-way merge tool such as kdiff3. This setup is not necessary if your changes are simple; keeping all of your modifications at the beginning or end of the file is a good strategy to keep merges easy.

FAQs

Should I commit the contrib modules I download?

Composer recommends no. They provide argumentation against but also workarounds if a project decides to do it anyway.

Should I commit the scaffolding files?

The Drupal Composer Scaffold plugin can download the scaffold files (like index.php, update.php etc.) to the web directory of your project. If you have not customized those files you could choose to not check them into your version control system (e.g. git). If that is the case for your project, it might be convenient to automatically run the drupal-scaffold plugin after every install or update of your project. You can achieve that by registering @composer drupal:scaffold as post-install and post-update command in your composer.json:

"scripts": {
    "post-install-cmd": [
        "@composer drupal:scaffold",
        "..."
    ],
    "post-update-cmd": [
        "@composer drupal:scaffold",
        "..."
    ]
},

How can I apply patches to included dependencies?

If you need to apply patches, you can do so with the composer-patches plugin included in this project.

To add a patch to Drupal module foobar, insert the patches section in the extra section of composer.json:

"extra": {
    "patches": {
        "drupal/foobar": {
            "Patch description": "URL or local path to patch"
        }
    }
}

How do I specify a PHP version?

There are 2 places where Composer will be looking for PHP version requirements when resolving dependencies:

  1. The require.php version value in composer.json.
  2. The config.platform version value in composer.json.

The purpose of require.php is to set the minimum PHP language requirements for a package. For example, the minimum version required for Drupal 10.0 is 8.0.2 or above, which can be specified as >=8.

The purpose of config.platform is to set the PHP language requirements for the specific instance of the package running in the current environment. For example, while the minimum version required for Drupal 10 is 8.0.2 or above, the actual PHP version on the hosting provider could be 8.1.0. The value of this field should provide your exact version of PHP with all 3 parts of the version.

Which versions to specify in my Drupal site?

This project includes drupal/core which already has require.php added. Your would inherit that constraint. There is no need to add require.php to your composer.json.

config.platform is a platform-specific. It is recommended to specify config.platform as a specific version (e.g.8.1.19) constraint to ensure that only the package versions supported by your current environment are used.

"config": {
    "platform": {
        "php": "8.1.19"
    }
},

drupal-project's People

Contributors

alexskrypnyk avatar bradjones1 avatar derhasi avatar gagarine avatar grasmash avatar greg-1-anderson avatar jcnventura avatar jmolivas avatar jnoordsij avatar jonhattan avatar jorissteyn avatar leymannx avatar matthieuscarset avatar mickaelperrin avatar mikran avatar milkovsky avatar modulesunraveled avatar mpparsley avatar opdavies avatar paulvandenburg avatar petk avatar pfrenssen avatar rodrigoaguilera avatar rwanyoike avatar skywardray avatar tannguyen04 avatar thom8 avatar webflo avatar weitzman avatar zaporylie avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

drupal-project's Issues

Composer install deletes modules and themes

This may be related to #1 and #5, but this project should have a huge disclaimer: DO NOT put your modules or themes in the normal place! composer install or composer update may delete them all if drupal/drupal updates or re-installs.

Here are the basic steps to reproduce:

composer create-project drupal-composer/drupal-project:7.x-dev --stability dev --no-interaction drupal_site
cd drupal_site
mkdir web/sites/all/themes/example
mkdir web/sites/all/modules/example
touch web/sites/all/themes/example/example.info
touch web/sites/all/modules/example/example.info
# vendor isn't committed to repo...
rm -rf vendor
# now to wipe out all my work in themes and modules
composer install

I now see that my themes and modules should have been placed in a contrib sub-directory, but I don't think I'd be the first to make that mistake. Is there a reason not to preserve paths on the themes and modules directories themselves?

Timeout causes preserve-paths to be lost

Hello,

I've noticed that since you provided the new composer.json to use with Drupal 7 you are using composer-preserve-paths. The problem while using this new method is that if for example git.drupal.org times out while trying to pull the latest version, your web/ folder will be empty and all your custom codes won't be restored even if the files are in your preserve-paths. This seems a bit risky to lose uncommitted code while running a composer install to make sure that something is working or is updated...

Is there something i am not understanding properly?

Workflow to update Drupal Core

Based on the information in README.md, I tried updating from drupal-8.0.0-rc2 to drupal-8.0.0-rc3 by running composer update drupal/core and then scripts/drupal/update-scaffold. Now my settings.php and public files folder are gone. What is the correct workflow to update Drupal Core and not lose these files?

How to handle module library dependencies

I'm enjoying the workflow for building out a new D8 site, but I'm looking at installing a module that has 3rd party requirements and am wondering what is the best practice for something like this?

Document how to use forks

I was trying to use https://github.com/md-systems/pathauto for pathauto in my composer.json since the drupal packagist version is outdated.

I was using

"repositories": [
    {
        "type": "composer",
        "url": "https://packagist.drupal-composer.org"
    },
    {
        "type": "vcs",
        "url": "https://github.com/md-systems/pathauto"
    }
],

Then

     composer require "drupal/pathauto": "dev-8.x-1.x"

But the packagist repo takes priority over the md-systems fork. You just have to change the order in the repositories section.

I spent some hours on this so I think is worth it document it somehow.
Where can I put it?

Composer cannot find the drupal-scaffold command in post-install.sh

I have tweaked the DOCUMENTROOT variable in post-install.sh to be something else because "web" won't work for us as a directory name.

I have also tweaked the "drupal-composer/drupal-scaffold" to use "dev-use-better-apis" because of the apparent bug preventing the main branch from working at the moment.

Everything seems to download fine in composer, but then the post-install.sh script has issues straight away.

The vendor dir definitely contains the class in question, but I don't know enough about this side of composer to know why it apparently cannot find the drupal-scaffold command as defined.

> sh ./scripts/composer/post-install.sh
./scripts/composer/post-install.sh: line 8: composer: command not found
cp: cannot stat `docroot/sites/default/default.settings.php': No such file or di
rectory
chmod: getting attributes of `docroot/sites/default/settings.php': No such file
or directory
Create a sites/default/settings.php file with chmod 666
cp: cannot stat `docroot/sites/default/default.services.yml': No such file or di
rectory
chmod: getting attributes of `docroot/sites/default/services.yml': No such file
or directory
Create a sites/default/services.yml services.yml file with chmod 666
mkdir: cannot create directory `docroot/sites/default/files': No such file or di
rectory
chmod: getting attributes of `docroot/sites/default/files': No such file or dire
ctory
Create a sites/default/files directory with chmod 777

AmazonS3

http://pastebin.com/kSuidsse

@webflo This may be an issue with composer-merge-plugin instead (or even more likely user error on my part). However, when I add the above patch to my code, it works when I the amazons3 module already exists, but when doing a fresh build from Composer, it fails as it can't find the yet-to-be-download amazons3 composer.json. Am I going about this the wrong way, or perhaps missing something?

Example of using git revision of module

I have been pulling my hair to use a git revision to use in composer.json, but I can not seem to get it to work, this is what I am using right now:

"require": {
        "drupal/devel": "dev-8.x-1.x#d913e1d"
}

What happens is that latest commit from HEAD is used. Is there a way around this? The "simple" way around it is to fork and tag the commit, but I would like to avoid that.

How to use drush?

When we are in the web directory, we can run drush like this:

cd web
../vendor/drush/drush/drush cr

Dumb question, but is there a better way to do it?

We can't currently add a symlink to the web directory, because the drush directory is already there.

cd web
ln -s ../vendor/drush/drush
ln: failed to create symbolic link ‘./drush’: File exists

Document how to use a different web-root instead of 'web'

Acquia Cloud requires Drupal in a subdir named 'docroot' but this project uses 'web'. The 'web' name is used in scripts in addition to composer.json. Is there some better solution for changing this than find/replace? Would be good to document this somewhere (I volunteer).

composer.json and Drupal root issue

Hey,

I run into this issue when I installed the Composer Manager module (https://www.drupal.org/project/composer_manager) After installing this module I keep getting the following errors:

RuntimeException: \web\composer.json is not readable.

This is caused by the fact that the Drupal root is set to be the web folder - but the project root folder where the composer.json is saved is the folder above "web". All the trouble appears in composer_manager.module here:

`function composer_manager_initialized($root = NULL) {
$root = $root ?: \Drupal::root();
$package = \Drupal\composer_manager\JsonFile::read($root . '/composer.json');

return isset($package['scripts']['drupal-rebuild']);
}`

Where Drupal::root()gives back "web". I feel that it still not really clear where to save the composer.json? Or maybe this project here is already outdated? (see https://bojanz.wordpress.com/2015/09/18/d8-composer-definitive-intro/)... or is this blog article outdated?

Best,
Tobias

Split drush commands folder into contrib / custom ?

Just like for modules and themes, a site will use contrib drush commands, and also develop a set of custom ones.

The former will be downloaded as composer packages, the latter will be committed in place in the repo, so there should be two separate folders ?

Why is git remote origin pointing to the project after installation?

Installed the package with no issues, but now that I'm modifying files it's unclear why the git remote origin is pointing to git://github.com/drupal-composer/drupal-project.git I obviously don't want to push my customizations to this Github project.

I know I could change the origin to my own git repo and push/pull as usual, but want to make sure I'm doing it the way that's intended.

Sorry if I missed the documentation, but I read the Readme and multiple tutorials on the drupal-composer way and the only thing they say is not to commit /vendors, which I understand.

What I'm talking about is committing changes to my composer.json, /sites and eventually custom module and theme code.

I'm glad to put in time writing up more info for a Readme or Wiki page if this is something simple like changing the remote origin after install.

post-install script fails to run on Windows

The composer post install command fails on Windows with the following error message:

'scripts' is not recognized as an internal or external command,
operable program or batch file.
Script scripts/composer/post-install.sh handling the post-install-cmd event returned with an error

  [RuntimeException]
  Error Output: 'scripts' is not recognized as an internal or external command,
  operable program or batch file.

I did a quick Github search: filename:composer.json q:post-install-cmd*.sh and noticed most projects run shell scripts with bash.

When I update the scripts property in composer.json the problem is resolved:

"scripts": {
  "post-install-cmd": "bash ./scripts/composer/post-install.sh"
}

How to use autoload files from other projects?

I'm trying to install drupal/webprofiler, which has the following composer.json:

{
    "name": "drupal/webprofiler",
    "description": "",
    "type": "drupal-webprofiler",
    "license": "GPL-2.0+",
    "require": {
        "symfony/stopwatch": "2.4.*"
    },
    "autoload": {
        "files": [
            "vendor/symfony/stopwatch/Symfony/Component/Stopwatch/Stopwatch.php"
        ]
    }
}

This gives me a fatal error, because composer is trying to find that file in a vendor folder inside that module. How should this be fixed, so that files is looking for files in the root vendor folder?

Add a config folder and entry to default.settings.php

$config_directories['git'] = '../config/';

We'd also add a config/.gitkeep file as a placeholder. This would by default set up an external directory to commit cmi to should developers be keeping that information in the repo.

Standarize on patch workflow/plugins

We have a few different composer plugins to apply patches files after a package is installed.

I forked jpstaceys repos because i think its very convenient to manage all patches in the root composer.json file. And because of our own packagist we dont have the package definition in our composer.json. This means, we need to store this information somewhere else.

// cc @kasperg, @derhasi, @greg-1-anderson, @frega, @jpstacey: Whats your opinion?

Move config directories (et al.) out of the webroot

It is a best practice to move as much as possible outside of the webroot. Specifically Drupal's config directories are stored inside of the webroot by default, but they really should be placed outside if possible. Because we have the dedicated web directory for the webroot, we can easily do this in the template, so that everyone using it automatically benefits from the added security measure.

We simply have to change

$config_directories = array();

in the default.settings.php to

$config_directories[CONFIG_SYNC_DIRECTORY] = '../config/sync';

Some questions/problems arise from this, however (which is why I did not do a pull request directly):

  1. Naming Just like the web directory, people might have different naming patterns. I always use config for this, but people might have non-Drupal-specific config in their repos or whatever.
  2. The update-scaffold script when run, would revert any custom modifications to the default.settings.php so I think we should find a solution to that before doing any custom modifications. One possibility would be to also commit a patch file, which the update-scaffold script then applies. Not sure.

Anyway, wanted to put this out there, so we can discuss.

Once we have figured this out, we should (IMO) also move private files (!!!) and also translation files out of the webroot, but I thought config was a good place to start.

how to deal with non-drupal dependencies of drupal modules?

I wanted to install https://www.drupal.org/project/webprofiler.

composer create-project drupal-composer/drupal-project:8.x-dev dc1 --stability dev --no-interaction
cd dc1
composer require "drupal/webprofiler:8.2.0-beta15"

Error message was as follows:

./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/webprofiler 8.2.0-beta15 -> satisfiable by drupal/webprofiler[8.2.0-beta15].
    - drupal/webprofiler 8.2.0-beta15 requires isagalaev/highlight.js 8.* -> no matching package found.

Potential causes:
 - A typo in the package name
 - The package is not available in a stable-enough version according to your minimum-stability setting
   see <https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion> for more details.

Read <https://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.

Installation failed, reverting ./composer.json to its original content.

I wonder what the problem is here? Is it that https://packagist.drupal-composer.org does not know about isagalaev/highlight.js?

Ah. I guess I need to add github under "repositories". Will try that tomorrow :)

querying drupal modules for release support/recommendations using composer?

I've created a new drupal project with composer

composer create-project \
 drupal-composer/drupal-project \
 --stability dev \
 ./d8
cd ./d8

If I wish to explore then install a given module with drush, it provides a clear infication of available releases, relevant to the install drupal version, as well as providing release state/recommendation.

E.g. for 'search_api'

drush dl --select search_api
    Choose one of the available releases for drupal:
     [0]  :  Cancel                                                 
     [1]  :  8.1.x-dev    -  2016-Jan-15  -  Development            
     [2]  :  8.0.2        -  2016-Jan-06  -  Supported, Recommended 
     [3]  :  8.0.0-beta2  -  2014-Oct-15  -  Security

otoh, composer's a fair bit more verbose

composer show drupal/search_api
    name     : drupal/search_api
    descrip. : Provides a generic framework for modules offering search capabilities.
    keywords : 
    versions : 8.1.x-dev, 8.1.0-alpha11, 8.1.0-alpha10, 8.1.0-alpha9, 8.1.0-alpha8, 8.1.0-alpha7, 8.1.0-alpha6, 8.1.0-alpha5, 8.1.0-alpha4, 8.1.0-alpha3, 8.1.0-alpha2, 8.1.0-alpha1, 7.1.x-dev, 7.1.16, 7.1.15, 7.1.14, 7.1.13, 7.1.12, 7.1.11, 7.1.10, 7.1.9, 7.1.8, 7.1.7, 7.1.6, 7.1.5, 7.1.4, 7.1.3, 7.1.2, 7.1.1, 7.1.0, 7.1.0-rc1, 7.1.0-beta10, 7.1.0-beta9, 7.1.0-beta8, 7.1.0-beta7, 7.1.0-beta6, 7.1.0-beta5, 7.1.0-beta4, 7.1.0-beta3, 7.1.0-beta2, 7.1.0-beta1, dev-8.x-1.x, dev-8.x-1.x-facetapi, dev-7.x-1.x
    type     : drupal-module
    license  : GPL-2.0+
    source   : [git] http://git.drupal.org/project/search_api 6bda8589b05f452544e6c489543b15b5e77c0d0e
    dist     : []  
    names    : drupal/search_api, drupal/search_api_db, drupal/search_api_db_defaults

    requires
    drupal/core 8.*

    suggests
    drupal/core Required by drupal/search_api_db, drupal/search_api_db_defaults

    replaces
    drupal/search_api_db self.version
    drupal/search_api_db_defaults self.version
    drupal/search_api_db 8.1.x-dev
    drupal/search_api_db_defaults 8.1.x-dev

with no clear indication, as invoked, of "Supported, Recommended" release.

IS there currently a cmd-line method/workflow for getting that info out of composer? Or is drush still needed?

delete the duplicate web/core/vendor in post-install.sh ?

All dependencies, including core's, are downloaded by composer in the root /vendor, and this is the directory that is targetted by the web/autoloader.php that is effectively used by the drupal code.

So the web/core/vendor that is currently committed in the core repo is dead code, and just adds confusion (triggers duplicates when navigating the codebase in an IDE...)

Uncomment default.settings.php local.settings.php area

default.settings.php comes with the following lines commented out:

# if (file_exists(__DIR__ . '/settings.local.php')) {
#   include __DIR__ . '/settings.local.php';
# }

These should be uncommented by default going forward. Acquia hosting does this by default and now more and more drupal projects would like to use settings.php as a configuration piece for non-sensitive information while db connection info is kept in local.settings.php

This also may require edits to .gitignore. I haven't provided a pr for this but am more than willing once we have a discussion/ it's decided it's a good direction for the project.

Neat project!

Where are you going to go with it? What's needed to push it forwards? There's also http://hubdrop.org/ which will mirror Drupal modules/themes on GitHub. Might be a bit handy as Packagist has pretty solid GitHub integration.

Explain correct autoloaded setup

Hi, I'm trying to get drupal/console installed on a newly minted drupal 8 project, but it keeps getting the dependencies wrong.

drupal/console tries to load the autoload file it finds in web/core/vendor/autoload.php but I see there is also one in $root/vendor/autoload.php. How should this work?

I also seem to have a full vendors dir in $root/vendors and in $root/web/core/vendors , why?

I do not think I did anything wrong in the project setup, but I would love to get rid of the web/core/vendors file and keep my tree clean. Is that possible?

Remove Drupal Console

Drupal Console has instructions for global install. I think there's no reason to treat it otherwise.

The main problem with the current approach is that it gets put into vendor/bin/console, while all output actually suggests typing only "drupal" (assuming a global install under the "drupal" name).
This creates confusion in docs, at sprints, etc.

Windows: Resource temporarily unavailable

I tried to install drupal with this project to see what it has to offer but I got the following error. I'm on Windows 10 and I'm using mingw64 that comes with git.

Writing lock file
Generating autoload files
> sh ./scripts/composer/post-install.sh
      0 [main] sh 12020 C:\Users\ijaro\AppData\Local\Programs\Git\usr\bin\sh.exe: *** fatal error in forked process - fork: can't reserve memory for parent stack 0x600000 - 0x800000, (child has 0x400000 - 0x600000), Win32 error 487
   3195 [main] sh 12020 cygwin_exception::open_stackdumpfile: Dumping stack trace to sh.exe.stackdump
      0 [main] sh 7648 fork: child -1 - forked process 12020 died unexpectedly, retry 0, exit code 0x100, errno 11
./scripts/composer/post-install.sh: fork: retry: No child processes
1006539 [main] sh 11836 C:\Users\ijaro\AppData\Local\Programs\Git\usr\bin\sh.exe: *** fatal error in forked process - fork: can't reserve memory for parent stack 0x600000 - 0x800000, (child has 0x400000 - 0x600000), Win32 error 487
1009018 [main] sh 11836 cygwin_exception::open_stackdumpfile: Dumping stack trace to sh.exe.stackdump
1041931 [main] sh 7648 fork: child -1 - forked process 11836 died unexpectedly, retry 0, exit code 0x100, errno 11
./scripts/composer/post-install.sh: fork: retry: No child processes
3047777 [main] sh 8764 C:\Users\ijaro\AppData\Local\Programs\Git\usr\bin\sh.exe: *** fatal error in forked process - fork: can't reserve memory for parent stack 0x600000 - 0x800000, (child has 0x400000 - 0x600000), Win32 error 487
3050134 [main] sh 8764 cygwin_exception::open_stackdumpfile: Dumping stack trace to sh.exe.stackdump
3088144 [main] sh 7648 fork: child -1 - forked process 8764 died unexpectedly, retry 0, exit code 0x100, errno 11
./scripts/composer/post-install.sh: fork: retry: No child processes
7107630 [main] sh 10104 C:\Users\ijaro\AppData\Local\Programs\Git\usr\bin\sh.exe: *** fatal error in forked process - fork: can't reserve memory for parent stack 0x600000 - 0x800000, (child has 0x400000 - 0x600000), Win32 error 487
7110132 [main] sh 10104 cygwin_exception::open_stackdumpfile: Dumping stack trace to sh.exe.stackdump
7144412 [main] sh 7648 fork: child -1 - forked process 10104 died unexpectedly, retry 0, exit code 0x100, errno 11
./scripts/composer/post-install.sh: fork: retry: No child processes
15187175 [main] sh 10388 C:\Users\ijaro\AppData\Local\Programs\Git\usr\bin\sh.exe: *** fatal error in forked process - fork: can't reserve memory for parent stack 0x600000 - 0x800000, (child has 0x400000 - 0x600000), Win32 error 487
15188478 [main] sh 10388 cygwin_exception::open_stackdumpfile: Dumping stack trace to sh.exe.stackdump
15222249 [main] sh 7648 fork: child -1 - forked process 10388 died unexpectedly, retry 0, exit code 0x100, errno 11
./scripts/composer/post-install.sh: fork: Resource temporarily unavailable
Script sh ./scripts/composer/post-install.sh handling the post-install-cmd event returned with an error



  [RuntimeException]
  Error Output:       0 [main] sh 12020 C:\Users\ijaro\AppData\Local\Programs\Git\usr\bin\sh.exe: *** fatal error in
  forked process - fork: can't reserve memory for parent stack 0x600000 - 0x800000, (child has 0x400000 - 0x600000),
  Win32 error 487
     3195 [main] sh 12020 cygwin_exception::open_stackdumpfile: Dumping stack trace to sh.exe.stackdump
        0 [main] sh 7648 fork: child -1 - forked process 12020 died unexpectedly, retry 0, exit code 0x100, errno 11
  ./scripts/composer/post-install.sh: fork: retry: No child processes
  1006539 [main] sh 11836 C:\Users\ijaro\AppData\Local\Programs\Git\usr\bin\sh.exe: *** fatal error in forked process
   - fork: can't reserve memory for parent stack 0x600000 - 0x800000, (child has 0x400000 - 0x600000), Win32 error 48
  7
  1009018 [main] sh 11836 cygwin_exception::open_stackdumpfile: Dumping stack trace to sh.exe.stackdump
  1041931 [main] sh 7648 fork: child -1 - forked process 11836 died unexpectedly, retry 0, exit code 0x100, errno 11
  ./scripts/composer/post-install.sh: fork: retry: No child processes
  3047777 [main] sh 8764 C:\Users\ijaro\AppData\Local\Programs\Git\usr\bin\sh.exe: *** fatal error in forked process
  - fork: can't reserve memory for parent stack 0x600000 - 0x800000, (child has 0x400000 - 0x600000), Win32 error 487
  3050134 [main] sh 8764 cygwin_exception::open_stackdumpfile: Dumping stack trace to sh.exe.stackdump
  3088144 [main] sh 7648 fork: child -1 - forked process 8764 died unexpectedly, retry 0, exit code 0x100, errno 11
  ./scripts/composer/post-install.sh: fork: retry: No child processes
  7107630 [main] sh 10104 C:\Users\ijaro\AppData\Local\Programs\Git\usr\bin\sh.exe: *** fatal error in forked process
   - fork: can't reserve memory for parent stack 0x600000 - 0x800000, (child has 0x400000 - 0x600000), Win32 error 48
  7
  7110132 [main] sh 10104 cygwin_exception::open_stackdumpfile: Dumping stack trace to sh.exe.stackdump
  7144412 [main] sh 7648 fork: child -1 - forked process 10104 died unexpectedly, retry 0, exit code 0x100, errno 11
  ./scripts/composer/post-install.sh: fork: retry: No child processes
  15187175 [main] sh 10388 C:\Users\ijaro\AppData\Local\Programs\Git\usr\bin\sh.exe: *** fatal error in forked proces
  s - fork: can't reserve memory for parent stack 0x600000 - 0x800000, (child has 0x400000 - 0x600000), Win32 error 4
  87
  15188478 [main] sh 10388 cygwin_exception::open_stackdumpfile: Dumping stack trace to sh.exe.stackdump
  15222249 [main] sh 7648 fork: child -1 - forked process 10388 died unexpectedly, retry 0, exit code 0x100, errno 11
  ./scripts/composer/post-install.sh: fork: Resource temporarily unavailable

Unable to patch drupal itself

Hi ! I'm using this method to manage my project and it have been working great until I had to apply a path to Drupal itself.
With drush make, I would have done something like that:

projects[drupal][patch][] = "https://www.drupal.org/files/911354-drupal-profile-85.patch"

So I have tried to use the method described in the Patches section but I couldn't get it to work, it keeps getting me this error:

  Failing patch detected - reverting already applied patches

  [Netresearch\Composer\Patches\PatchCommandException]
  Patch 0 would fail!
  Error executing command "patch -f -p1 --no-backup-if-mismatch -r - --dry-run":
  can't find file to patch at input line 5
  Perhaps you used the wrong -p or --strip option?
  The text leading up to this was:
  --------------------------
  |diff --git a/includes/bootstrap.inc b/includes/bootstrap.inc
  |index 80563ef..80a7b5a 100644
  |--- a/includes/bootstrap.inc
  |+++ b/includes/bootstrap.inc
  --------------------------
  No file to patch.  Skipping patch.
  1 out of 1 hunk ignored
  can't find file to patch at input line 33
  Perhaps you used the wrong -p or --strip option?
  The text leading up to this was:
  --------------------------
  |diff --git a/includes/common.inc b/includes/common.inc
  |index 31923f2..b722db2 100644
  |--- a/includes/common.inc
  |+++ b/includes/common.inc
  --------------------------
  No file to patch.  Skipping patch.
  1 out of 1 hunk ignored
  can't find file to patch at input line 46
  Perhaps you used the wrong -p or --strip option?
  The text leading up to this was:
  --------------------------
  |diff --git a/modules/simpletest/drupal_web_test_case.php b/modules/simpletest/drupal_web_test_case.php
  |index 0853c7d..74acb13 100644
  |--- a/modules/simpletest/drupal_web_test_case.php
  |+++ b/modules/simpletest/drupal_web_test_case.php
  --------------------------
  No file to patch.  Skipping patch.
  1 out of 1 hunk ignored

I am using these plugins in my project:

  • azt3k/non-destructive-archive-installer
  • netresearch/composer-patches-plugin
  • composer/installers

Here is my composer.json file so you may tell me what's wrong with it (it's not the actual one but it illustrates the problem correctly):

{
  "name": "me/my-project",
  "minimum-stability": "beta",
  "prefer-stable": true,
  "repositories": [{
    "type": "package",
    "package": {
      "name": "drupal/drupal",
      "type": "non-destructive-archive-installer",
      "version": "7.35",
      "dist": {
        "url": "http://ftp.drupal.org/files/projects/drupal-7.35.zip",
        "type": "zip"
      },
      "require": {
        "azt3k/non-destructive-archive-installer": "*"
      },
      "extra": {
        "target-dir": ".",
        "omit-first-directory": "true",
        "patches": {
          "drupal/drupal": {
            "7.35": [
              {
                "title": "Tests in profiles/[name]/modules cannot be run and cannot use a different profile for running tests",
                "url": "https://www.drupal.org/files/911354-drupal-profile-85.patch"
              }
            ]
          }
        }
      }
    }
  }, {
    "type": "composer",
    "url": "http://packagist.drupal-composer.org/"
  }],
  "require": {
    "azt3k/non-destructive-archive-installer": "0.2.*",
    "netresearch/composer-patches-plugin": "~1.0",
    "composer/installers": "~1.0",

    "drupal/drupal": "7.35"
  },
  "config": {
    "vendor-dir": "sites/all/vendor"
  },
  "extra": {
    "installer-paths": {
      "sites/all/modules/contrib/{$name}/": ["type:drupal-module"],
      "sites/all/themes/contrib/{$name}/": ["type:drupal-theme"],
      "sites/all/libraries/{$name}/": ["type:drupal-library"],
      "sites/all/drush/{$name}/": ["type:drupal-drush"],
      "profiles/{$name}/": ["type:drupal-profile"]
    }
  }
}

My best guess would be that it's an incompatibility between the non-destructive-archive-installer plugin and composer-patches-plugin because the latter is not aware that the former changes the installation path of the package, but I'm not quite sure.

How does one handle custom modules in 7.x?

Hi!

I think unlike Drupal 8, modules can be stored just inside the modules/ directory. I'm wondering how I should handle this in the 7.x branch? All packages would be inside web so I guess if I have custom modules I could put them inside web/sites/all/modules/custom though what's going to happen now is that if I track these custom modules in git, I need to track the files inside web - specifically web/sites/all/modules/custom/* (and I was hoping to completely ignore the web directory). Would like to know what's a clean approach for this.

Generate hash_salt while install

If you have an active project based on this repo and someone has cloned it and running locally he gets php throwable error, because Drupal is required a hash salt.
So is it secure to generate hash_salt in post-install script via this command?
echo "\$settings['hash_salt'] = '$(php -r 'print bin2hex(openssl_random_pseudo_bytes(32, $cstrong = TRUE));')';" >> web/sites/default/settings.php

Can't install modules with core dependencies

I have the following repositories:

{
    "repositories": [
        {
            "type": "composer",
            "url": "https://raw.githubusercontent.com/webflo/d8/master/packages.json"
        },
        {
            "type": "composer",
            "url": "https://packagist.drupal-composer.org"
        }
    ]
}

For example:

$ composer require 'drupal/page_manager 8.*'
./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
    - drupal/page_manager 8.1.x-dev requires drupal/block 8.* -> no matching package found.
    - drupal/page_manager 8.1.0-alpha9 requires drupal/block 8.* -> no matching package found.
    - drupal/page_manager 8.1.0-alpha8 requires drupal/block 8.* -> no matching package found.
    - drupal/page_manager 8.1.0-alpha7 requires drupal/block 8.* -> no matching package found.
    - drupal/page_manager 8.1.0-alpha6 requires drupal/block 8.* -> no matching package found.
    - drupal/page_manager 8.1.0-alpha3 requires drupal/block 8.* -> no matching package found.
    - drupal/page_manager 8.1.0-alpha2 requires drupal/block 8.* -> no matching package found.
    - drupal/page_manager 8.1.0-alpha10 requires drupal/block 8.* -> no matching package found.
    - Installation request for drupal/page_manager 8.* -> satisfiable by drupal/page_manager[8.1.0-alpha10, 8.1.0-alpha2, 8.1.0-alpha3, 8.1.0-alpha6, 8.1.0-alpha7, 8.1.0-alpha8, 8.1.0-alpha9, 8.1.x-dev].

Potential causes:
 - A typo in the package name
 - The package is not available in a stable-enough version according to your minimum-stability setting
   see <https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion> for more details.

Read <https://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.

Installation failed, reverting ./composer.json to its original content.

Shouldn't a show work?

$ composer show drupal/block

  [InvalidArgumentException]
  Package drupal/block not found

Permission denied

"composer create-project" command dies with error:

[ErrorException]                          
  touch(): Utime failed: Permission denied  

Is sudo required?

Pantheon?

Lovely project. Has anyone used this successfully with Pantheon? They assume that the Drupal site lives in the root of the repo (not the web) subdirectory.

Document how to apply patches

One of the most common questions that I get when people are switching from drush makefiles is "how do you apply patches". I'm aware that patches are ideally a thing of the past, but supporting them makes the transition easier.

The answer is to use https://github.com/cweagans/composer-patches, which has some pretty clear instructions, a simple reference to that project in the FAQ should be sufficient.

no matches found: drupal/devel:8.*

After installing Drupal 8 using drupal-composer I wanted to download devel.

Following the instructions in the README I tried this:

composer require drupal/devel:8.*

and got this error:

zsh: no matches found: drupal/devel:8.*

This works however

composer require drupal/devel

I got this:

Using version 8.1.x-dev for drupal/devel
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
  - Updating drupal/devel dev-8.x-1.x (8e745a9 => 9a331e7)
    Checking out 9a331e760b2ffa32a1271a155a74cb3fab213e62

Was I using the wrong syntax?

Does README.md need to be updated?

Discuss using GPL instead of MIT

Can we have a discussion about the license for this project? I am in favour of using GPL instead of MIT because it is copyleft and better protects the interests of the project, end-users as well as clients that are ultimately paying for the work that is being done.

PHP file-based warnings followed by an ERROR?

Thanks for this project. I'm really excited to be using Composer rather than Drush Make, much as I've loved the latter over the years.

When I run your example command locally, composer installs all of its dependencies, then writes the lock and autoload files.... and then after

Extracting /tmp//drupal-scaffold-1455809014/drupal-8.0.3.tar.gz

I get a number of PHP warnings:

PHP Warning:  rename(): The first argument to copy() function cannot be a directory in /ROOT/vendor/drupal-composer/drupal-scaffold/src/Extract.php on line 70
PHP Stack trace:
...
PHP  12. rename() /var/www/personal/drupal8-magneticphield/some-dir/vendor/drupal-composer/drupal-scaffold/src/Extract.php:70

Warning: rename(): The first argument to copy() function cannot be a directory in /var/www/personal/drupal8-magneticphield/some-dir/vendor/drupal-composer/drupal-scaffold/src/Extract.php on line 70

Call Stack:
...
   17.9383    5397824  12. rename() /var/www/personal/drupal8-magneticphield/some-dir/vendor/drupal-composer/drupal-scaffold/src/Extract.php:70

PHP Warning:  rename(/var/www/personal/drupal8-magneticphield/some-dir/vendor/drupal-composer/drupal-scaffold/scripts/tmp17716083661455809031/drupal-8.0.3,/tmp//drupal-scaffold-1455809014/drupal-8): Invalid cross-device link in /var/www/personal/drupal8-magneticphield/some-dir/vendor/drupal-composer/drupal-scaffold/src/Extract.php on line 70
PHP Stack trace:.
...
PHP  12. rename() /var/www/personal/drupal8-magneticphield/some-dir/vendor/drupal-composer/drupal-scaffold/src/Extract.php:70

Warning: rename(/var/www/personal/drupal8-magneticphield/some-dir/vendor/drupal-composer/drupal-scaffold/scripts/tmp17716083661455809031/drupal-8.0.3,/tmp//drupal-scaffold-1455809014/drupal-8): Invalid cross-device link in /var/www/personal/drupal8-magneticphield/some-dir/vendor/drupal-composer/drupal-scaffold/src/Extract.php on line 70

Call Stack:
...

etc. I wouldn't mind them being PHP warnings, but the entire process ends with:

 [Remote\Rsync] Running rsync -a -v -z --include 'sites' --include 'sites/default' --include 'sites/default/default.settings.php' --include 'sites/default/default.services.yml' --include 'sites/development.services.yml' --include 'sites/example.settings.local.php' --include 'sites/example.sites.php' --exclude '.gitkeep' --exclude 'autoload.php' --exclude 'composer.json' --exclude 'composer.lock' --exclude 'core' --exclude 'drush' --exclude 'example.gitignore' --exclude 'LICENSE.txt' --exclude 'README.txt' --exclude 'vendor' --exclude 'themes' --exclude 'profiles' --exclude 'modules' --exclude 'sites/*' --exclude 'sites/default/*' /tmp//drupal-scaffold-1455809014/drupal-8/ /var/www/personal/drupal8-magneticphield/some-dir/web
sending incremental file list
rsync: change_dir "/tmp//drupal-scaffold-1455809014/drupal-8" failed: No such file or directory (2)

sent 20 bytes  received 12 bytes  64.00 bytes/sec
total size is 0  speedup is 0.00
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1183) [sender=3.1.0]
 [Remote\Rsync] sending incremental file list
 [Remote\Rsync] sent 20 bytes  received 12 bytes  64.00 bytes/sec
 [Remote\Rsync] total size is 0  speedup is 0.00
 [Remote\Rsync]  Exit code 23  Time 0.153s
 [Robo\Result] Stopping on fail. Exiting....
 [Robo\Result] Exit Code: 23
ERROR: rmdir(/var/www/personal/drupal8-magneticphield/some-dir/vendor/drupal-composer/drupal-scaffold/scripts/tmp17716083661455809031): Directory not empty 
in /var/www/personal/drupal8-magneticphield/some-dir/vendor/drupal-composer/drupal-scaffold/src/Extract.php:71

cp: cannot stat ‘web/sites/default/default.settings.php’: No such file or directory
chmod: cannot access ‘web/sites/default/settings.php’: No such file or directory
Create a sites/default/settings.php file with chmod 666
cp: cannot stat ‘web/sites/default/default.services.yml’: No such file or directory
chmod: cannot access ‘web/sites/default/services.yml’: No such file or directory
Create a sites/default/services.yml services.yml file with chmod 666
Create a sites/default/files directory with chmod 777

(I've attached [a full paste](%28https://github.com/drupal-composer/drupal-project/files/136456/drupal-composer-perm-probs.txt%29 of my command and the output.)

The site that ends up being produced is somewhat functional, but e.g web/sites/default is completely empty. So I'm loath to go any further!

Any ideas? I've asked a couple of people on IRC and I've had confirmation it can be repeated, but they think it was working yesterday; maybe a recent change?

drupal-composer-perm-probs.txt

Document how to merge in composer.json of local extensions

TL;DR : I created a plugin at https://github.com/yched/composer-local-modules, that handles composer.json's from locally committed custom modules and themes. I propose we include it in the composer.json template shipped in the project.

Rationale :

composer_manager.module took care of collecting composer.json's from contrib and custom alike. We intend to make composer_manager obsolete, but currently don't cater for custom code.

One could say that, since those modules are custom to the project and part of the project repo, their dependencies have to be directly added to the project root composer.json.

However, this is not ideal for a couple reasons:

  • you lose track of which module requires what, all dependencies of all custom code are mushed together in the root composer.json. This defeats efforts for structuring custom code into clear units, and after a while, this adds to maintainance burden.
  • there are cases when patching is not enough, and you want to take a contrib module and commit a fork locally (even temporarily). In those cases, you'd need to manually integrate its requires into your root composer.json (and remove them later when you unfork the module and get back to the contrib version)
  • when develpping/maintaining your own contrib module locally, you want to keep its local composer.json as the official one, without manually mirror it into the main composer.json

It is more convenient to allow custom modules to have their own composer.json, and include them as part of dependency solving just like for contrib modules (since a custom module can become contrib, and reversedly).

https://github.com/yched/composer-local-modules uses a custom, local repository type that discovers custom modules/themes with a composer.json and automatically adds them as requires in the root package. This happens at runtime on composer install/update, so it leaves the root composer.json untouched, but tracks the corresponding packages them in composer.lock and installed.json)

Could not authenticate against github.com

OK it's only noise, but is there any way of preventing composer create-project drupal-composer/drupal-project:8.x-dev my-composer-project --stability dev --no-interaction producing loads of these authentication warnings (example below) as it tries the repo before the source and successfully installing the dependency?

` - Installing doctrine/instantiator (1.0.5)
Downloading: Connecting... Failed to download doctrine/instantiator from dist: Could not authenticate against github.com
Now trying to download from source

  • Installing doctrine/instantiator (1.0.5)
    Cloning 8e884e78f9f0eb1329e445619e04456e64d8051d`

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.