### Start and Install EC-CUBE with Docker Compose Source: https://doc4.ec-cube.net/quickstart/install_docker-compose_405orlower This snippet shows how to start EC-CUBE containers and run the initial installation script. It requires navigating to the EC-CUBE directory and executing docker-compose commands. The installation script must be run as the 'www-data' user. ```bash cd path/to/ec-cube # コンテナの起動 (初回のみビルド処理あり) docker-compose up -d # 初回はインストールスクリプトを実行( **`www-data` ユーザで実行する点に注意!** ) docker-compose exec -u www-data ec-cube bin/console eccube:install ``` -------------------------------- ### Start Specific EC-CUBE Services with Docker Compose Source: https://doc4.ec-cube.net/quickstart/install_docker-compose_405orlower Instructions on how to start specific services within the Docker Compose setup for EC-CUBE. This allows for selective launching of containers like the web server, database, or mail catcher. Omitting service names starts all defined services. ```bash # 例:EC-CUBEとMySQLとphpMyAdminとMailCatcherを起動する docker-compose up -d ec-cube mysql mailcatcher # 省略した場合はすべてのサービスが起動します docker-compose up -d ``` -------------------------------- ### EC-CUBE Installation with Docker Compose Source: https://doc4.ec-cube.net/quickstart/docker_compose_install Commands to set up and install EC-CUBE using Docker Compose. This includes starting containers and running the initial installation script in non-interactive mode. Assumes Docker Desktop is installed. ```bash cd path/to/ec-cube # Start containers (builds on first run) docker-compose up -d # Run the installation script (use www-data user, non-interactive mode) docker-compose exec -u www-data ec-cube bin/console eccube:install -n ``` ```bash # Start containers docker-compose up -d # Stop containers docker-compose down ``` -------------------------------- ### Install Plugin Dependencies with Composer Source: https://doc4.ec-cube.net/update42x This example illustrates how to install specific dependencies for plugins, such as the 'API plugin', by examining its composer.json file and then using Composer to install the required libraries. This is important for maintaining plugin compatibility after an upgrade. ```bash $ cat app/Plugin/Api/composer.json ... "require": { "ec-cube/plugin-installer": "~0.0.6 || ^2.0", "trikoder/oauth2-bundle": "^2.1", "nyholm/psr7": "^1.2", "webonyx/graphql-php": "^14.0" $ composer require trikoder/oauth2-bundle:^2.1 --no-plugins --no-scripts $ composer require nyholm/psr7:^1.2 --no-plugins --no-scripts $ composer require webonyx/graphql-php:^14.0 --no-plugins --no-scripts ``` -------------------------------- ### Run EC-CUBE Built-in Web Server Source: https://doc4.ec-cube.net/quickstart/composer_web_installer After navigating into the EC-CUBE project directory, this command starts the built-in web server. This server allows you to access the EC-CUBE installation interface through your web browser. ```bash cd ec-cube php bin/console server:run ``` -------------------------------- ### Run EC-CUBE Built-in Web Server Source: https://doc4.ec-cube.net/quickstart/command_install After installation, navigate into the created ec-cube directory and run this command to start the built-in web server for development. Access the admin panel at http://127.0.0.1:8000/admin. Press Ctrl+C to stop the server. ```shell cd ec-cube php bin/console server:run --env=dev ``` -------------------------------- ### Install EC-CUBE 4 via Composer Source: https://doc4.ec-cube.net/quickstart/command_install This snippet outlines the process of installing EC-CUBE 4 using Composer. It involves navigating to the desired directory, updating Composer to a compatible version, and then creating the EC-CUBE project. The default setup uses SQLite3, and users on macOS might need to install the php-intl extension. ```shell cd /path/to/your/directory php composer.phar selfupdate --1 php composer.phar create-project ec-cube/ec-cube ec-cube "4.1.x-dev" --keep-vcs ``` -------------------------------- ### Start OWASP ZAP Container (Shell) Source: https://doc4.ec-cube.net/penetration-testing/quick_start This command initiates the OWASP ZAP container using docker-compose. Note that addon updates may take some time upon initial startup. ```shell docker-compose -f docker-compose.yml -f docker-compose.owaspzap.yml up -d zap ``` -------------------------------- ### EC-CUBE Local Development Mount with Docker Compose Source: https://doc4.ec-cube.net/quickstart/docker_compose_install Configures EC-CUBE for local development using Docker Compose by mounting local directories. This example shows how to combine MySQL configuration with the development mount. ```bash ## Example using MySQL docker-compose -f docker-compose.yml -f docker-compose.mysql.yml -f docker-compose.dev.yml up -d ``` -------------------------------- ### EC-CUBE Installation with MySQL using Docker Compose Source: https://doc4.ec-cube.net/quickstart/docker_compose_install Installs EC-CUBE using Docker Compose, specifically configuring it to use MySQL. This involves specifying the MySQL configuration file and optionally running database schema initialization. ```bash docker-compose -f docker-compose.yml -f docker-compose.mysql.yml up -d ``` ```bash # Initialize database schema and initial data (if not already done) docker-compose -f docker-compose.yml -f docker-compose.mysql.yml exec ec-cube composer run-script compile ``` -------------------------------- ### EC-CUBE Installation with PostgreSQL using Docker Compose Source: https://doc4.ec-cube.net/quickstart/docker_compose_install Installs EC-CUBE using Docker Compose, specifically configuring it to use PostgreSQL. This involves specifying the PostgreSQL configuration file and optionally running database schema initialization. ```bash docker-compose -f docker-compose.yml -f docker-compose.pgsql.yml up -d ``` ```bash # Initialize database schema and initial data (if not already done) docker-compose -f docker-compose.yml -f docker-compose.pgsql.yml exec ec-cube composer run-script compile ``` -------------------------------- ### Run Mock Server and Configure Environment (Shell) Source: https://doc4.ec-cube.net/plugin_mock_package_api This snippet details the steps to set up and run a mock server for the Owner's Store, configure the EC-CUBE environment to use the mock server, and place a plugin for testing. It requires Docker and assumes EC-CUBE is installed. ```shell # Move to the root directory of ec-cube $ cd /path/to/ec-cube # Create a directory for storing plugins $ mkdir ${PWD}/repos # Start the mock server. Port 9999 is used here, but you can change it as needed. docker run -d --rm -v ${PWD}/repos:/repos -e MOCK_REPO_DIR=/repos -p 9999:8080 eccube/mock-package-api # Define environment variable to reference the mock server echo ECCUBE_PACKAGE_API_URL=http://127.0.0.1:9999 >> .env # Set authentication key psql eccube_db -h 127.0.0.1 -U postgres -c "update dtb_base_info set authentication_key='test';" # Place the plugin in the repos directory. Change the extension to tgz. cp /path/to/SamplePlugin.tar.gz repos/SamplePlugin.tgz ``` -------------------------------- ### Manage EC-CUBE Docker Containers Source: https://doc4.ec-cube.net/quickstart/install_docker-compose_405orlower Commands to manage the lifecycle of EC-CUBE Docker containers. This includes starting containers for subsequent sessions and stopping them when not in use. These commands are executed from the project's root directory. ```bash # コンテナの起動 docker-compose up -d # コンテナの停止 docker-compose down ``` -------------------------------- ### Get Repository from EntityManager in PluginManager Source: https://doc4.ec-cube.net/update-40-41 In the PluginManager, direct service retrieval using `$container->get()` is not supported for repositories. Instead, obtain the EntityManager first and then use it to get the desired repository. ```php - $pageRepository = $container->get(PageRepository::class); + $entityManager = $container->get('doctrine')->getManager(); + $pageRepository = $entityManager->getRepository(Page::class); ``` -------------------------------- ### EC-CUBE Installation Commands for Windows Source: https://doc4.ec-cube.net/quickstart/command_install For Windows environments, the `eccube:install` command is not directly usable. Instead, use these individual commands to manage database creation and schema generation. This sequence includes optional steps for dropping existing databases and schemas. ```shell # (optional) Delete database php bin/console doctrine:database:drop --force # Create database php bin/console doctrine:database:create # (optional) Delete schema php bin/console doctrine:schema:drop --force # Generate schema php bin/console doctrine:schema:create # Generate initial data php bin/console eccube:fixtures:load ``` -------------------------------- ### Start Development Web Server using CLI Source: https://doc4.ec-cube.net/quickstart/cli This command starts a built-in web server for development purposes. It allows you to test your EC-CUBE application locally without setting up a separate web server. ```bash php bin/console server:run ``` -------------------------------- ### EC-CUBE インストール時言語指定 (.env.install) Source: https://doc4.ec-cube.net/i18n_multilingualization EC-CUBEのインストール時に使用する言語を指定するには、ルートディレクトリ直下の`.env.install`ファイルで`ECCUBE_LOCALE`を設定します。これにより、インストール時のマスタデータ等が指定した言語でインポートされます。 ```env //.env.install ECCUBE_LOCALE=en ``` -------------------------------- ### Install Dependencies with Composer Source: https://doc4.ec-cube.net/contribution-guide/pull-request Installs the necessary packages for the project. This command reads the `composer.json` file to download and set up dependencies. ```bash $ composer install ``` -------------------------------- ### Install External Libraries with Composer Source: https://doc4.ec-cube.net/update42x This code snippet shows how to use Composer to install external libraries, such as 'psr/http-message', required for EC-CUBE functionality. The '--no-plugins' and '--no-scripts' flags are used to prevent plugin and script execution during installation, which can be crucial during version upgrades. ```bash composer require psr/http-message --no-plugins --no-scripts ``` -------------------------------- ### Launch and Stop MailCatcher with Docker Compose Source: https://doc4.ec-cube.net/development-tools/mail-catcher Commands to start and stop MailCatcher containers using Docker Compose. `docker-compose up -d` starts the services in detached mode, while `docker-compose down` stops and removes them. ```bash $ docker-compose up -d $ docker-compose down ``` -------------------------------- ### EC-CUBEコンテナの設定ファイル編集 Source: https://doc4.ec-cube.net/quickstart/docker_install EC-CUBEコンテナ内の設定ファイル(例: .env)を編集するためのコマンドです。`docker exec`を使用してコンテナに接続し、`vi`などのエディタでファイルを編集します。 ```bash docker exec -it ec-cube /bin/bash root@de5372ce7139:/var/www/html# vi .env ``` -------------------------------- ### EC-CUBE Dockerイメージのビルドと実行 Source: https://doc4.ec-cube.net/quickstart/docker_install EC-CUBEのDockerイメージをビルドし、コンテナを実行する基本的なコマンドです。コンテナ内のファイルを使用する場合と、ローカルディレクトリをマウントする場合の2つのシナリオをカバーしています。ローカルディレクトリのマウント時には、パフォーマンス上の理由から特定のディレクトリのみをマウントすることが推奨されています。 ```bash cd path/to/ec-cube docker build -t eccube4-php-apache . ## コンテナ上のファイルを使用する場合 docker run --name ec-cube -p "8080:80" -p "4430:443" eccube4-php-apache ## ローカルディレクトリをマウントする場合 # var 以下をマウントすると強烈に遅くなるため、 src, html, app 以下のみをマウントする docker run --name ec-cube -p "8080:80" -p "4430:443" -v "$PWD/html:/var/www/html/html:cached" -v "$PWD/src:/var/www/html/src:cached" -v "$PWD/app:/var/www/html/app:cached" eccube4-php-apache ``` -------------------------------- ### Apacheでの環境変数設定例 Source: https://doc4.ec-cube.net/quickstart/dotenv Apacheのhttpd.confまたは.htaccessファイルにSetEnvディレクティブを使用して環境変数を設定する例です。これにより、EC-CUBEアプリケーションが必要とする設定をサーバーレベルで管理できます。 ```apache SetEnv APP_ENV prod SetEnv APP_DEBUG 0 SetEnv DATABASE_URL pgsql://dbuser:password@127.0.0.1/cube4_dev SetEnv DATABASE_SERVER_VERSION 10.5 SetEnv ECCUBE_AUTH_MAGIC 8PPlCHZVdH5vbMkIUKeuTeDHycQQMuaB SetEnv ECCUBE_ADMIN_ALLOW_HOSTS [] SetEnv ECCUBE_FORCE_SSL false SetEnv ECCUBE_ADMIN_ROUTE admin SetEnv ECCUBE_COOKIE_PATH / ``` -------------------------------- ### Require plugin dependencies with Composer Source: https://doc4.ec-cube.net/update423_43x This snippet demonstrates how to install specific library dependencies for a plugin, such as an API plugin, by examining its composer.json file and using 'composer require' for each listed dependency. This ensures all necessary libraries are correctly installed. ```shell $ cat app/Plugin/Api42/composer.json ... "require": { "ec-cube/plugin-installer": "^2.0", "league/oauth2-server-bundle": "^0.5", "nyholm/psr7": "^1.2", "php-http/message-factory": "*", "webonyx/graphql-php": "^14.0" $ composer require league/oauth2-server-bundle:^0.5 --no-plugins --no-scripts $ composer require nyholm/psr7:^1.2 --no-plugins --no-scripts $ composer require php-http/message-factory --no-plugins --no-scripts $ composer require webonyx/graphql-php:^14.0 --no-plugins --no-scripts ``` -------------------------------- ### Run EC-CUBE Composer: Require Already Installed Command Source: https://doc4.ec-cube.net/update42x This command is part of the EC-CUBE upgrade process and is used to ensure that all necessary packages are correctly installed and registered after composer.json and composer.lock have been updated. It helps resolve potential dependency issues. ```bash bin/console eccube:composer:require-already-installed ``` -------------------------------- ### EC-CUBEコンテナの再起動 Source: https://doc4.ec-cube.net/quickstart/docker_install 一度停止したEC-CUBEコンテナを再度起動するためのコマンドです。コンテナが既に存在し、停止している場合にのみ使用します。 ```bash docker start --attach ec-cube ``` -------------------------------- ### Bash: EC-CUBE Proxyクラス生成とDBスキーマ更新 Source: https://doc4.ec-cube.net/reverse-lookup/sample-code/add-youtube-to-product-detail TraitによるEntity拡張後、`bin/console eccube:generate:proxies`コマンドでProxyクラスを生成します。その後、`bin/console doctrine:schema:update`コマンドを使用して、変更されたスキーマ定義をデータベースに反映させます。キャッシュクリアも必要に応じて実行します。 ```bash bin/console eccube:generate:proxies ## 作成した Proxy クラスを確実に認識できるようキャッシュを削除 bin/console cache:clear --no-warmup ## 実行する SQL を確認 bin/console doctrine:schema:update --dump-sql ## SQL を実行 bin/console doctrine:schema:update --dump-sql --force ``` -------------------------------- ### Add return types to setUp and tearDown methods Source: https://doc4.ec-cube.net/update-41-42 Adds return type declarations (`void`) to the `setUp` and `tearDown` methods in test classes. This is a requirement in newer PHP versions and frameworks like Symfony 5.4 to ensure type safety in test execution. ```php - setUp() + setUp(): void - tearDown() + tearDown(): void ``` -------------------------------- ### Install EC-CUBE using CLI Source: https://doc4.ec-cube.net/quickstart/cli This snippet demonstrates how to install EC-CUBE using the command-line interface. It requires navigating to the EC-CUBE root directory and executing the `eccube:install` command. Command name can be abbreviated. ```bash cd [ec-cube ルートディレクトリ] php bin/console eccube:install # Abbreviated command php bin/console e:i ``` -------------------------------- ### Manage MailCatcher Docker Container Source: https://doc4.ec-cube.net/development-tools/mail-catcher Commands to stop and start the MailCatcher Docker container. These are essential for managing the email server during development. ```bash # コンテナの停止 $ docker stop mailcatcher # コンテナの再起動 $ docker start mailcatcher ``` -------------------------------- ### Require External Library - Composer Command Source: https://doc4.ec-cube.net/update If you have manually installed external libraries using packagist, such as 'psr/http-message', you need to re-require them after the upgrade. This command ensures compatibility with the new EC-CUBE version. ```bash composer require psr/http-message ``` -------------------------------- ### ローカル開発環境の立ち上げ Source: https://doc4.ec-cube.net/co/co_customize_dir_usage Docker Composeを使用してEC-CUBEのローカル開発環境を立ち上げ、初期設定を行うためのコマンド群です。docker-compose up, docker-compose exec, bin/consoleコマンドを使用します。 ```bash $ docker-compose -f docker-compose.yml -f docker-compose.pgsql.yml -f docker-compose.dev.yml up $ docker-compose exec -u www-data ec-cube bin/console eccube:install --no-interaction $ docker-compose exec -u www-data ec-cube bin/console eccube:generate:proxies $ docker-compose exec -u www-data ec-cube bin/console doctrine:schema:update --force --dump-sql $ docker-compose exec -u www-data ec-cube bin/console doctrine:migrations:migrate ``` -------------------------------- ### PostgreSQLを使用したデータベース設定 Source: https://doc4.ec-cube.net/quickstart/docker_install PostgreSQLデータベースを使用してEC-CUBEをセットアップする手順です。まず、PostgreSQLコンテナを起動し、EC-CUBEコンテナの`.env`ファイルで`DATABASE_URL`を設定します。その後、EC-CUBEコンテナをPostgreSQLコンテナにリンクさせて起動します。 ```bash ## .env にて DATABASE_URL=pgsql://postgres:password@db/cube4_dev としておく docker run --name container_postgres -e POSTGRES_PASSWORD=password -p 5432:5432 -d postgres docker run --name ec-cube -p "8080:80" -p "4430:443" --link container_postgres:db eccube4-php-apache ``` -------------------------------- ### Configure EC-CUBE with PostgreSQL Database Source: https://doc4.ec-cube.net/quickstart/install_docker-compose_405orlower Configuration for using PostgreSQL as the database for EC-CUBE. The `.env` file needs to be updated with the `DATABASE_URL` pointing to the PostgreSQL container. If the database schema is not initialized, a `compile` command is required. ```env DATABASE_URL=postgres://dbuser:secret@postgres/eccubedb ```