Laravel/Install Aimeos

From Aimeos documentation

Other languages:
English 100%

If you use Laravel 5.4+ and don't have the latest MySQL version installed, you will probably get an error like Specified key was too long; max key length is 767 bytes. To circumvent this problem, you should change the database charset/collation in your config/database.php file before the tables are created to:

  1.  'mysql' => [
  2.      // ...
  3.      'charset' => 'utf8',
  4.      'collation' => 'utf8_unicode_ci',
  5.      // ...
  6.  ]

The Aimeos Laravel web shop package is a composer based library that can be installed easiest by using Composer. Add these lines to your composer.json of your Laravel project:

  1.     "prefer-stable": true,
  2.     "minimum-stability": "dev",
  3.     "require": {
  4.         "aimeos/aimeos-laravel": "~2018.07",
  5.         ...
  6.     },
  7.     "scripts": {
  8.         ...
  9.         "post-update-cmd": [
  10.             "php artisan vendor:publish --tag=public --force",
  11.             "php artisan migrate",
  12.             ...
  13.         ]
  14.     }

The additional line in the require section tells composer to install the Aimeos Laravel package. You can also use the "dev-master" branch name if you want to install the latest version. Please have a look at the Aimeos Packagist page to find out what branches and versions are available.

To enable the use of the latest development version, you have to set the minimum-stability option to dev. Otherwise, composer might fail with an error that the library dependency can't be resolved.

The scripts in post-update-cmd will make sure that the CSS/Javascript files and your database will be up to date after an update.

In previous versions an additional section "repositories" was required in the composer.json file. This is not the case any more and have to be removed! Otherwise, composer will ask you for the credentials of a private repository that doesn't exist.

Make sure that the database is set up and it is configured in your .env file. Sometimes, the .env files are not available in the Laravel application and you will get exceptions that the connection to the database failed. In that case, add the database credentials to the resource/db section of your ./config/shop.php file too!

Afterwards, you can install the Aimeos shop package by executing this command on the command line:

composer update

Next, the Aimeos provider class must be added to the providers array of the config/app.php file so you are able to run the Aimeos Laravel tasks:

  1. return array(
  2.     'providers' => array(
  3.         ...
  4.         Aimeos\Shop\ShopServiceProvider::class,
  5.     ),
  6. );

The Aimeos package provides a setup task that automatically sets up your Laravel application for Aimeos and creates or updates the required database tables used by Aimeos. This is done by executing these four commands:

php artisan vendor:publish
php artisan migrate
php artisan aimeos:setup --option=setup/default/demo:1
php artisan aimeos:cache

Note: If you are encountering an error during setup, please make sure that you've executed php artisan vendor:publish first! In a production environment or if you don't want that the demo data gets installed, leave out the --option=setup/default/demo:1 option.

Since Laravel 5.0 CSRF protection is enabled by default but for the /confirm and /update routes, you may have to disable CSRF if one of the payment providers is sending data via POST requests. More details about excluding CSRF for routes can be found in the Laravel documentation

<< Previous: Upgrade from previous versions | Next: Create the base template >>