Giter Site home page Giter Site logo

project-base's Introduction

Commerce 2.x project template

Use Composer to get Drupal + Commerce 2.x.

Also look at drupalcommerce/demo-project for a version with demo content.

Usage

First you need to install composer.

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.

After that you can create the project:

composer create-project drupalcommerce/project-base some-dir --stability dev --no-interaction

Done! Use composer require ... to download additional modules and themes:

cd some-dir
composer require "drupal/devel:1.x-dev"

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.

What does the template do?

  • Drupal will be installed in the web-directory.
  • Autoloader is implemented to use the generated composer autoloader in vendor/autoload.php, instead of the one provided by Drupal (web/vendor/autoload.php).
  • Modules (packages of type drupal-module) will be placed in web/modules/contrib/
  • Theme (packages of type drupal-theme) will be placed in web/themes/contrib/
  • Profiles (packages of type drupal-profile) will be placed in web/profiles/contrib/
  • Creates default writable versions of settings.php and services.yml.
  • Creates web/sites/default/files-directory.
  • Latest version of drush is installed locally for use at vendor/bin/drush.
  • Creates environment variables based on your .env file. See .env.example.

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 core files.

  1. Run composer update drupal/core drupal/core-dev --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.

Generate composer.json from existing project

With using the "Composer Generate" drush extension you can now generate a basic composer.json file from an existing project. Note that the generated composer.json might differ from this project's file.

FAQ

Should I commit the contrib modules I download?

Composer recommends no. They provide argumentation against but also workrounds 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, …) 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 downloaded modules?

If you need to apply patches (depending on the project being modified, a pull request is often a better solution), you can do so with the composer-patches plugin.

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 to patch"
        }
    }
}

How can I add js/css libraries using composer.json?

It is possible to install JavaScript libraries with Composer using custom packages as this project does. We previously relied on asset-packagist to do this but had to change our approach after the repository went defunct. Refer to this tutorial for more information.

How do I specify a PHP version?

This project supports PHP 8.1 as minimum version (see Environment requirements of Drupal 10), however it's possible that a composer update will upgrade some package that will then require PHP 8.1+.

To prevent this you can add this code to specify the PHP version you want to use in the config section of composer.json:

"config": {
    "sort-packages": true,
    "platform": {
        "php": "8.1.13"
    }
},

project-base's People

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

project-base's Issues

Installation fails without being able to download

Am sadly not able to install this. Please see the details below:

user@user-laptop /var/www/html/ $ composer create-project drupalcommerce/project-base some-dir --stability dev --no-interaction
The "https://packagist.org/packages.json" file could not be downloaded: php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution
failed to open stream: php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution
https://packagist.org could not be fully loaded, package information was loaded from the local cache and may be out of date
Installing drupalcommerce/project-base (8.x-dev 32daa518b57f33da8824dbf04f1ecc66e0ce4284)
  - Installing drupalcommerce/project-base (8.x-dev 32daa51) Cloning 32daa518b5 from cache
    Failed to download drupalcommerce/project-base from source: Failed to clone https://github.com/drupalcommerce/project-base.git via https, ssh protocols, aborting.

- https://github.com/drupalcommerce/project-base.git
  Cloning into 'some-dir'...
  fatal: unable to access 'https://github.com/drupalcommerce/project-base.git/': Could not resolve host: github.com

- [email protected]:drupalcommerce/project-base.git
  Cloning into 'some-dir'...
  ssh: Could not resolve hostname github.com: Temporary failure in name resolution
  fatal: Could not read from remote repository.
  
  Please make sure you have the correct access rights
  and the repository exists.

    Now trying to download from dist
  - Installing drupalcommerce/project-base (8.x-dev 32daa51) Downloading: Failed       
 Downloading: Failed       
 Downloading: Failed       
                                                                                                
  [Composer\Downloader\TransportException]                                                      
  The "https://api.github.com/repos/drupalcommerce/project-base/zipball/32daa518b57f33da8824db  
  f04f1ecc66e0ce4284" file could not be downloaded: php_network_getaddresses: getaddrinfo fail  
  ed: Temporary failure in name resolution                                                      
  failed to open stream: php_network_getaddresses: getaddrinfo failed: Temporary failure in na  
  me resolution                                                                                 
                                                                                                

create-project [-s|--stability STABILITY] [--prefer-source] [--prefer-dist] [--repository REPOSITORY] [--repository-url REPOSITORY-URL] [--dev] [--no-dev] [--no-custom-installers] [--no-scripts] [--no-progress] [--no-secure-http] [--keep-vcs] [--no-install] [--ignore-platform-reqs] [--] [<package>] [<directory>] [<version>]


Error on Site Install: Error: Class 'Drupal\shortcut\Entity\Shortcut' not found in commerce_base_install()

After setting up a new project with composer create-project ... I was greeted with the following error on site install:

Error
The website encountered an unexpected error. Please try again later.
Error: Class 'Drupal\shortcut\Entity\Shortcut' not found in commerce_base_install() (line 25 of profiles/contrib/commerce_base/commerce_base.install).
commerce_base_install()
call_user_func_array('commerce_base_install', Array) (Line: 392)
Drupal\Core\Extension\ModuleHandler->invoke('commerce_base', 'install', Array) (Line: 328)
Drupal\Core\Extension\ModuleInstaller->install(Array, ) (Line: 83)
Drupal\Core\ProxyClass\Extension\ModuleInstaller->install(Array, ) (Line: 1649)
install_install_profile(Array) (Line: 690)
install_run_task(Array, Array) (Line: 565)
install_run_tasks(Array, NULL) (Line: 118)
install_drupal(Object) (Line: 48)

Anyone else having this issue?

Document that composer doesn't work from web/

Anyone sane would run composer foo bar from web/ but no. That doesn't work and there are no sensible error messages either just a Could not find package drupal/whatever. It only works from the docroot.

Upgrade from swift mailer to symfony mailer

I have try to install symfony mailer and unistall swift mailer.
As I can see to have a proper synfony mailer install, I have to remove mailsystem and swift mailer module, right? Can I use symfony mail with mailsystem and swift installed and enabled?
But I cannot uninstall swift mailer as I get

The following reason prevents Swift Mailer from being uninstalled:
Required by: commerce_base

I attach my composer.json here to help me how can I remove swift mailer and install symfony mailer

`{
"name": "drupalcommerce/project-base",
"description": "Commerce 2.x project template",
"type": "project",
"license": "GPL-2.0-or-later",
"authors": [
{
"name": "",
"role": ""
}
],
"repositories": {
"drupal": {
"type": "composer",
"url": "https://packages.drupal.org/8"
},
"commerce_base": {
"type": "vcs",
"url": "https://github.com/drupalcommerce/commerce_base"
},
"asset-packagist": {
"type": "composer",
"url": "https://asset-packagist.org"
},
"commerce-price-rule": {
"type": "vcs",
"url": "https://github.com/krystalcode/drupal8-commerce-price-rule"
}
},
"config": {
"bin-dir": "bin",
"sort-packages": true
},
"require": {
"php": ">=7.0.8",
"ext-curl": "",
"composer/installers": "^1.9",
"cweagans/composer-patches": "~1.0",
"drupal/address": "^1.8",
"drupal/admin_toolbar": "^3.0",
"drupal/adminimal_admin_toolbar": "^1.11",
"drupal/adminimal_theme": "^1.6",
"drupal/backup_migrate": "^5.0",
"drupal/better_exposed_filters": "^5.0@beta",
"drupal/betterlogin": "^1.5",
"drupal/bootstrap_barrio": "^5.1",
"drupal/bootstrap_basic_image_gallery": "^1.5",
"drupal/captcha": "^1.1",
"drupal/chosen": "^3.0",
"drupal/commerce": "^2.26",
"drupal/commerce_ajax_atc": "^1.0@alpha",
"drupal/commerce_bcc_address_token": "^1.1",
"drupal/commerce_cart_flyout": "^1.8",
"drupal/commerce_feeds": "^1.0@alpha",
"drupal/commerce_migrate": "^3.1@alpha",
"drupal/commerce_price_rule": "1.x-dev@dev",
"drupal/commerce_product_limits": "^1.0",
"drupal/composer_deploy": "^1.6",
"drupal/core-project-message": "^9",
"drupal/core-recommended": "^9.3",
"drupal/devel": "^4.0",
"drupal/draggableviews": "^2.0",
"drupal/easy_breadcrumb": "^2.0",
"drupal/eu_cookie_compliance": "^1.19",
"drupal/features": "^3.12",
"drupal/feeds": "^3.0@alpha",
"drupal/feeds_ex": "^1.0@alpha",
"drupal/feeds_tamper": "^2.0@beta",
"drupal/field_group": "^3.1",
"drupal/field_permissions": "^1.1",
"drupal/field_validation": "^1.0@beta",
"drupal/filefield_paths": "^1.0@beta",
"drupal/fontawesome": "^2.17",
"drupal/ga": "^1.8",
"drupal/gin": "^3.0",
"drupal/gin_login": "^1.0",
"drupal/gin_toolbar": "^1.0@beta",
"drupal/google_analytics": "^4.0",
"drupal/image_effects": "^3.0",
"drupal/image_url_formatter": "^1.0",
"drupal/jquery_ui_accordion": "^1.1",
"drupal/lang_dropdown": "^2.0@beta",
"drupal/languageicons": "^1.0@beta",
"drupal/login_emailusername": "^1.2",
"drupal/mailsystem": "^4.3",
"drupal/menu_breadcrumb": "^1.14",
"drupal/metatag": "^1.16",
"drupal/migrate_cron": "^1.2",
"drupal/migrate_plus": "^5.1",
"drupal/migrate_process_skip": "^2.0",
"drupal/migrate_run": "^2.0@beta",
"drupal/migrate_source_csv": "^3.4",
"drupal/migrate_tools": "^5.0",
"drupal/mimemail": "^1.0@alpha",
"drupal/module_filter": "^3.1",
"drupal/pathauto": "^1.8",
"drupal/pathologic": "^1.0@alpha",
"drupal/recaptcha": "^3.0",
"drupal/redirect": "^1.6",
"drupal/responsive_menu": "^4.4",
"drupal/responsive_views_grid": "^1.1",
"drupal/rules": "3.x-dev@dev",
"drupal/schema_metatag": "^2.1",
"drupal/search_api": "^1.19",
"drupal/seo_checklist": "^5.0",
"drupal/simple_instagram_feed": "^3.6",
"drupal/simple_popup_blocks": "^2.8",
"drupal/simple_sitemap": "^3.8",
"drupal/state_machine": "^1.5",
"drupal/swiftmailer": "^2.2",
"drupal/symfony_mailer": "^1.0@alpha",
"drupal/tb_megamenu": "^2.0@alpha",
"drupal/token": "^1.7",
"drupal/twig_debugger": "^1.1",
"drupal/twig_field_value": "^2.0",
"drupal/twig_tweak": "^2",
"drupal/unused_modules": "^1.2",
"drupal/vefl": "^3.0",
"drupal/views_bootstrap": "^4.3",
"drupal/views_bulk_edit": "^2.4",
"drupal/views_bulk_operations": "^4.0",
"drupal/views_data_export": "^1.0",
"drupal/weight": "^3.2",
"drupal/yoast_seo": "^1.7",
"drupalcommerce/commerce_base": "9.x-dev",
"drush/drush": "^10",
"laminas/laminas-diactoros": "^2.8.0",
"laminas/laminas-escaper": "^2.9",
"laminas/laminas-feed": "^2.12",
"laminas/laminas-stdlib": "^3.2",
"oomphinc/composer-installers-extender": "^2.0",
"raveren/kint": "^3.1",
"webflo/drupal-finder": "^1.0.0",
"webmozart/path-util": "^2.3"
},
"require-dev": {
"drupal/core-dev": "^9",
"kint-php/kint": "^3.3"
},
"conflict": {
"drupal/drupal": "
"
},
"minimum-stability": "dev",
"prefer-stable": true,
"autoload": {
"classmap": [
"scripts/composer/ScriptHandler.php"
]
},
"scripts": {
"drupal-scaffold": "DrupalComposer\DrupalScaffold\Plugin::scaffold",
"pre-install-cmd": [
"DrupalProject\composer\ScriptHandler::checkComposerVersion"
],
"pre-update-cmd": [
"DrupalProject\composer\ScriptHandler::checkComposerVersion"
],
"post-install-cmd": [
"DrupalProject\composer\ScriptHandler::createRequiredFiles"
],
"post-update-cmd": [
"DrupalProject\composer\ScriptHandler::createRequiredFiles"
]
},
"extra": {
"composer-exit-on-patch-failure": true,
"patchLevel": {
"drupal/core": "-p2"
},
"drupal-scaffold": {
"locations": {
"web-root": "web/"
}
},
"installer-types": [
"bower-asset",
"npm-asset"
],
"installer-paths": {
"web/core": [
"type:drupal-core"
],
"web/libraries/{$name}": [
"type:drupal-library",
"type:bower-asset",
"type:npm-asset"
],
"web/modules/contrib/{$name}": [
"type:drupal-module"
],
"web/profiles/contrib/{$name}": [
"type:drupal-profile"
],
"web/themes/contrib/{$name}": [
"type:drupal-theme"
],
"drush/Commands/contrib/{$name}": [
"type:drupal-drush"
]
},
"patches": {
"drupal/address": {
"Address filed support for feeds": "https://www.drupal.org/files/issues/2019-04-19/address-feeds-address-target-2882589-23.patch"
},
"drupal/bootstrap_basic_image_gallery": {
"Template does not support Bootstrap v4": "https://www.drupal.org/files/issues/2020-11-04/template_doesnt_support_v4-3180586-8.patch"
},
"drupal/commerce": {
"Σωστός υπολογισμός ΦΠΑ στο σύνολο της παραγγελίας στο καλάθι": "https://www.drupal.org/files/issues/2020-06-01/allow-to-show-pretax-3143935-5.patch"
}
}
}

}`

Use d.o. packagist instance instead of drupal-composer.org's

The drupal-composer.org packagist instance is deprecated in favor of the d.o. version. Should this be reflected here and in the main commerce repo re: inclusion in the repositories list as well as in the version numbers? As it stands, there's some manual acrobatics required to include commerce via composer into a project that's using the d.o. packagist.

Maintainers' thoughts?

index.php and other files are missing

I have followed the commands provided in the documentation and the skeleton of directories was created as expected with one complication. There were no files created on root.

The index.php, .htaccess and other files are missing. I have tried updating core but the files were not created. Any suggestions please?

Remove Drush

composer/composer#4961 (comment) shows that the current version of the template resolves to about 107 packages. If --prefer-source is used, that's 107 (slow) git clones.

Now, Composer is working on speeding that up, but we should trim the fat on our side. We are currently shipping with two CLIs, Drush and Drupal Console. We use Drupal Console in our docs, Drush is unused. So let's remove it to speed up the initial install. People who want it can add it to their composer.json (or they might already use a globally installed one).

Installation failed

Thanks you for providing a project base with commerce.

Project creation with Composer and project-base was successful. But the installation both per UI or drupal site:install commerce_base don't function.
The error message is:
Fatal error: Symfony\Component\ClassLoader\ApcClassLoader::loadClass(): Failed opening required '/var/www/drupal/web/vendor/composer/../symfony/http-foundation/Response.php' (include_path='.:/usr/share/php') in /var/www/drupal/vendor/symfony/class-loader/ApcClassLoader.php on line 110

Odd path for the profile

web/profile ends up with:
commerce_base (empty)
contrib/commerce-base.

There should only be contrib/commerce_base (note the underscore instead of a dash)

Prepare for renaming

We are proposing to rename this template to drupalcommerce/commerce-project, inline with drupalcommerce/demo-project and centarro/commerce-kickstart-project

So all templates are hyphened and end in -project

Add drupal/token

Without the token contrib there are no tokens for Commerce entities, which is especially painful in Panels.

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.