EC-CUBE4.0-βでECサイトを作成してみた

September 01, 2018

2018年9月、ついにEC-CUBEのバージョン4.0がリリースされます。

それに先立って8月からβ版が公開されておりますので、サイトの構築方法紹介します。

「EC-CUBE」最新版に関するお知らせ(2018/08/06)

【9/1現在】※正式版はインストール方法が異なる可能性がありますので注意してください。

構築環境について

必要なミドルウェアが全てインストールされている前提で説明します。

$ cat /etc/redhat-release
CentOS Linux release 7.5.1804 (Core)

$ php -v
PHP 7.2.9 (cli) (built: Aug 15 2018 09:19:33) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies

$ composer --version
Composer version 1.7.2 2018-08-16 16:57:12

$ mysql --version
mysql  Ver 14.14 Distrib 5.7.23, for Linux (x86_64) using  EditLine wrapper

システム要件についてはこちらを確認してください。

システム要件 | EC-CUBE 4.0-beta 開発ドキュメント

インストール方法

今回は最新のソースコードを利用したいので、GitHubから直接取得します。

$ cd /var/www/html/
$ git clone -b 4.0 https://github.com/EC-CUBE/ec-cube.git

※上の例の場合、DocumentRoot/var/www/html/ec-cube/になります。

完了したらcomposer installでライブラリをインストールしましょう。

$ cd ec-cube/
$ composer install
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Package operations: 161 installs, 0 updates, 0 removals
:
:
Generating optimized autoload files
ocramius/package-versions:  Generating version class...
ocramius/package-versions: ...done generating version class
Executing script cache:clear --no-warmup [OK]
Executing script cache:warmup --no-optional-warmers [OK]
Executing script assets:install --symlink --relative html [OK]

Symfony3 + EC-CUBE4.0のコマンドが実行できるかbin/consoleと実行します。

$ bin/console
Symfony 3.4.12 (kernel: Eccube, env: dev, debug: true)

Usage:
command [options] [arguments]

Options:
-h, --help            Display this help message
-q, --quiet           Do not output any message
-V, --version         Display this application version
    --ansi            Force ANSI output
    --no-ansi         Disable ANSI output
-n, --no-interaction  Do not ask any interactive question
-e, --env=ENV         The Environment name. [default: "dev"]
    --no-debug        Switches off debug mode.
-v|vv|vvv, --verbose  Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Available commands:
about                                   Displays information about the current project
help                                    Displays help for a command
list                                    Lists commands
assets
assets:install                          Installs bundles web assets under a public directory
cache
cache:clear                             Clears the cache
cache:pool:clear                        Clears cache pools
cache:pool:prune                        Prunes cache pools
cache:warmup                            Warms up an empty cache
config
config:dump-reference                   Dumps the default configuration for an extension
debug
debug:autowiring                        Lists classes/interfaces you can use for autowiring
debug:config                            Dumps the current configuration for an extension
debug:container                         Displays current services for an application
debug:event-dispatcher                  Displays configured listeners for an application
debug:form                              Displays form type information
debug:router                            Displays current routes for an application
debug:swiftmailer                       Displays current mailers for an application
debug:translation                       Displays translation messages information
debug:twig                              Shows a list of twig functions, filters, globals and tests
doctrine
doctrine:cache:clear-collection-region  Clear a second-level cache collection region
doctrine:cache:clear-entity-region      Clear a second-level cache entity region
doctrine:cache:clear-metadata           Clears all metadata cache for an entity manager
doctrine:cache:clear-query              Clears all query cache for an entity manager
doctrine:cache:clear-query-region       Clear a second-level cache query region
doctrine:cache:clear-result             Clears result cache for an entity manager
doctrine:cache:contains                 Check if a cache entry exists
doctrine:cache:delete                   Delete a cache entry
doctrine:cache:flush                    [doctrine:cache:clear] Flush a given cache
doctrine:cache:stats                    Get stats on a given cache provider
doctrine:database:create                Creates the configured database
doctrine:database:drop                  Drops the configured database
doctrine:database:import                Import SQL file(s) directly to Database.
doctrine:ensure-production-settings     Verify that Doctrine is properly configured for a production environment
doctrine:fixtures:load                  Load data fixtures to your database.
doctrine:generate:entities              [generate:doctrine:entities] Generates entity classes and method stubs from your mapping information
doctrine:mapping:convert                [orm:convert:mapping] Convert mapping information between supported formats
doctrine:mapping:import                 Imports mapping information from an existing database
doctrine:mapping:info
doctrine:query:dql                      Executes arbitrary DQL directly from the command line
doctrine:query:sql                      Executes arbitrary SQL directly from the command line.
doctrine:schema:create                  Executes (or dumps) the SQL needed to generate the database schema
doctrine:schema:drop                    Executes (or dumps) the SQL needed to drop the current database schema
doctrine:schema:update                  Executes (or dumps) the SQL needed to update the database schema to match the current mapping metadata
doctrine:schema:validate                Validate the mapping files
eccube
eccube:composer:install
eccube:composer:remove
eccube:composer:require
eccube:composer:update
eccube:delete-carts                     Delete Carts from the database
eccube:fixtures:generate                Dummy data generator
eccube:fixtures:load                    Load data fixtures to your database.
eccube:generate:proxies                 Generate entity proxies
eccube:install                          Install EC-CUBE
eccube:plugin:disable
eccube:plugin:enable
eccube:plugin:generate                  Generate plugin skeleton.
eccube:plugin:install                   Install plugin from local.
eccube:plugin:uninstall                 Uninstall plugin.
lint
lint:twig                               Lints a template and outputs encountered errors
lint:xliff                              Lints a XLIFF file and outputs encountered errors
lint:yaml                               Lints a file and outputs encountered errors
make
make:auth                               Creates an empty Guard authenticator
make:command                            Creates a new console command class
make:controller                         Creates a new controller class
make:crud                               Creates CRUD for Doctrine entity class
make:entity                             Creates or updates a Doctrine entity class, and optionally an API Platform resource
make:fixtures                           Creates a new class to load Doctrine fixtures
make:form                               Creates a new form class
make:functional-test                    Creates a new functional test class
make:migration                          Creates a new migration based on database changes
make:serializer:encoder                 Creates a new serializer encoder class
make:subscriber                         Creates a new event subscriber class
make:twig-extension                     Creates a new Twig extension class
make:unit-test                          Creates a new unit test class
make:validator                          Creates a new validator and constraint class
make:voter                              Creates a new security voter class
router
router:match                            Helps debug routes by simulating a path info match
security
security:encode-password                Encodes a password.
server
server:log                              Starts a log server that displays logs in real time
server:run                              Runs a local web server
server:start                            Starts a local web server in the background
server:status                           Outputs the status of the local web server for the given address
server:stop                             Stops the local web server that was started with the server:start command
swiftmailer
swiftmailer:email:send                  Send simple email message
swiftmailer:spool:send                  Sends emails from the spool
translation
translation:update                      Updates the translation file
workflow
workflow:dump                           Dump a workflow

上記のように出力されれば大丈夫です。

準備が整ったのでインストール作業に移ります。

bin/console eccube:installと実行しましょう。

いろいろと設定内容を聞かれますが、DBメールサーバの情報だけ入力します。

$ bin/console eccube:install

EC-CUBE Installer Interactive Wizard
====================================

If you prefer to not use this interactive wizard, define the environment valiables as follows:

$ export APP_ENV=dev
$ export APP_DEBUG=1
$ export DATABASE_URL=database_url
$ export DATABASE_SERVER_VERSION=server_version
$ export MAILER_URL=mailer_url
$ export ECCUBE_AUTH_MAGIC=auth_magic
... and more
$ php bin/console eccube:install --no-interaction

# DB情報を入力
Database Url [sqlite:///%kernel.project_dir%/var/eccube.db]:
> mysql://127.0.0.1:3306/DB名?user=ユーザ名&password=パスワード

# そのままEnter
Database Server version [auto]:
>

# メールサーバ情報を入力
Mailer Url [null://localhost]:
> smtp://localhost:25

# そのままEnter
Auth Magic [JhDqJWJnNw2mICPi]:
>

!
! [CAUTION] Execute the installation process. All data is initialized.
!

# そのままEnter
Is it OK? (yes/no) [yes]:
>

Run doctrine:database:create --if-not-exists...
Created database `kuroneko` for connection named default

Run doctrine:schema:drop --force...

Dropping database schema...

[OK] Database schema dropped successfully!


Run doctrine:schema:create...

! [CAUTION] This operation should not be executed in a production environment!

Creating database schema...

[OK] Database schema created successfully!

Run eccube:fixtures:load...
> Finished Successful!

Run cache:clear --no-warmup...

// Clearing the cache for the dev environment with debug
// true

[OK] Cache for the "dev" environment (debug=true) was successfully cleared.

[OK] EC-CUBE installation successful.

インストールが完了しました!

確認してみましょう。

フロント画面

トップページにアクセスしてみましょう。

beta-1

今回のデフォルトはポップで可愛らしいですね。

管理画面

http://~/adminが管理画面のURLになります。

下記ID、パスワードでログインできます。

  • ログインID : admin
  • パスワード : password

ホーム画面が表示されたらおkです。

beta-2

まとめ

基本的にはEC-CUBE3.0系と同じようですが、より洗練され使いやすくなっているようです。

一通りプラグイン開発してみましたが、カスタマイズしやすくなっているのでエンジニアにとっても良いプラットフォームになっています。 ※と言ってもSymfony3の基礎が必要になるため、人気だったEC-CUBE2系と比べると難しいかも・・・

日々コミットされているようですので、正式リリースを楽しみに待ちましょう。

ではまた。

CONTACT

お問い合わせ

ECサイトやホームページの構築、保守・運用方法に課題を感じている方、まずはご相談ください。

お問い合わせ