Skip to content

Commit a4570d0

Browse files
bcremertaltholtmann
authored andcommitted
Initial Import
0 parents  commit a4570d0

File tree

30 files changed

+3491
-0
lines changed

30 files changed

+3491
-0
lines changed

.env.example

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
SHOPWARE_ENV=dev
2+
3+
DB_HOST=localhost
4+
DB_DATABASE=shopware
5+
DB_USERNAME=root
6+
DB_PASSWORD=root
7+
DB_PORT=3306
8+
9+
DATABASE_URL_NAME=DATABASE_URL
10+
DATABASE_URL=mysql://${DB_USERNAME}:${DB_PASSWORD}@${DB_HOST}:${DB_PORT}/${DB_DATABASE}
11+
12+
# Username and password for the initial admin account
13+
# This info will be populated into the database during initial installation.
14+
# After that, it can (and should) be removed from this .env file
15+
ADMIN_EMAIL=[email protected]
16+
ADMIN_NAME="Demo User"
17+
ADMIN_USERNAME=demo
18+
ADMIN_PASSWORD=demo
19+
20+
# Shop URL for initial shop configuration
21+
SHOP_URL=https://example.com
22+
23+
# Import demodata during initial shop installation
24+
IMPORT_DEMODATA=true

.gitignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/var/*
2+
!/var/cache
3+
/var/cache/*
4+
!var/cache/.gitkeep
5+
!/var/logs
6+
/var/logs/*
7+
!var/logs/.gitkeep
8+
/vendor/
9+
/web/cache/
10+
/web/media/
11+
/web/engine/
12+
/web/themes/
13+
.env

Plugins/Community/Backend/.gitkeep

Whitespace-only changes.

Plugins/Community/Core/.gitkeep

Whitespace-only changes.

Plugins/Community/Frontend/.gitkeep

Whitespace-only changes.

Plugins/Local/Backend/.gitkeep

Whitespace-only changes.

Plugins/Local/Core/.gitkeep

Whitespace-only changes.

Plugins/Local/Frontend/.gitkeep

Whitespace-only changes.

Procfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
web: vendor/bin/heroku-php-apache2 web/

README.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Composer template for Shopware projects
2+
3+
[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy)
4+
5+
## Warning
6+
7+
This is a proof of concept and not production ready.
8+
9+
## Installation
10+
11+
```
12+
composer create-project bcremer/shopware-composer-project my_project_name --no-interaction --stability=dev
13+
```
14+
15+
During installation `.env.example` is copied to `.env`.
16+
Please configure database credentials here.
17+
18+
```bash
19+
$ ./app/install.sh
20+
```
21+
22+
## Updating Shopware
23+
24+
Update the version number of shopware/shopware composer.json.
25+
Run composer update shopware/shopware.
26+
27+
## Plugins
28+
29+
Plugins are gettings installed into `Plugins/`.
30+
31+
### Prepare plugins for composer installation
32+
33+
Given you have a plugin called `SwagMediaSftp` (`Shopware_Plugins_Frontend_SwagMediaSftp_Bootstrap`) add your dependencies in your plugins `composer.json` file.
34+
Also set the `type` to `shopware-frontend-plugin`.
35+
36+
```
37+
{
38+
"name": "shopwarelabs/swag-media-sftp",
39+
"type": "shopware-frontend-plugin",
40+
"description": "The SFTP adapter allows you to manage your media files in shopware on a SFTP environment.",
41+
"license": "MIT",
42+
"extra": {
43+
"installer-name": "SwagMediaSftp"
44+
},
45+
"require": {
46+
"league/flysystem-sftp": "^1.0"
47+
}
48+
}
49+
```
50+

Themes/.gitkeep

Whitespace-only changes.

app.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"name": "Shopware on Herkou",
3+
"description": "Shopware, fully managed using Composer and configured using environment variables.",
4+
"keywords": [
5+
"php",
6+
"shopware",
7+
"ecommerce"
8+
],
9+
"website": "https://github.com/bcremer/shopware-composer-project",
10+
"repository": "https://github.com/bcremer/shopware-composer-project",
11+
"logo": "https://de.shopware.com/media/image/shopware_logo_blue.png",
12+
"success_url": "/",
13+
"scripts": {
14+
"postdeploy": "app/install.sh"
15+
},
16+
"env": {
17+
"DATABASE_URL_NAME": { "value": "JAWSDB_URL" },
18+
"ADMIN_EMAIL": { "description": "Administrator E-Mail" },
19+
"ADMIN_NAME": { "description": "Administrator Name", "value": "Demo Admin"},
20+
"ADMIN_USERNAME": { "description": "Administrator username", "value": "admin" },
21+
"ADMIN_PASSWORD": { "description": "Administrator password" },
22+
"SHOP_URL": { "value": "", "required": false},
23+
"IMPORT_DEMODATA": { "value": false },
24+
"SHOPWARE_ENV": { "value": "production" }
25+
},
26+
"addons": [
27+
"jawsdb:leopard"
28+
],
29+
"image": "heroku/php"
30+
}

app/AppKernel.php

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
use Shopware\Kernel;
4+
use Symfony\Component\Config\FileLocator;
5+
use Symfony\Component\DependencyInjection\ContainerBuilder;
6+
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
7+
8+
class AppKernel extends Kernel
9+
{
10+
/**
11+
* @return string
12+
*/
13+
protected function getConfigPath()
14+
{
15+
return __DIR__.'/config/config.php';
16+
}
17+
18+
/**
19+
* @return string
20+
*/
21+
public function getCacheDir()
22+
{
23+
return dirname(__DIR__).'/var/cache/'.$this->getEnvironment();
24+
}
25+
26+
/**
27+
* Gets the log directory.
28+
*
29+
* @return string The log directory
30+
*/
31+
public function getLogDir()
32+
{
33+
return dirname(__DIR__).'/var/logs';
34+
}
35+
36+
protected function prepareContainer(ContainerBuilder $container)
37+
{
38+
$loader = new XmlFileLoader($container, new FileLocator(__DIR__));
39+
$loader->load('services.xml');
40+
41+
return parent::prepareContainer($container);
42+
}
43+
}

app/autoload.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
use Doctrine\Common\Annotations\AnnotationRegistry;
4+
use Composer\Autoload\ClassLoader;
5+
use Dotenv\Dotenv;
6+
7+
/**
8+
* @var ClassLoader $loader
9+
*/
10+
$loader = require __DIR__.'/../vendor/autoload.php';
11+
12+
AnnotationRegistry::registerLoader([$loader, 'loadClass']);
13+
14+
15+
if (file_exists(__DIR__ . '/../.env')) {
16+
$dotenv = new Dotenv(__DIR__ . '/../');
17+
$dotenv->load();
18+
}
19+
20+
define('PUBLICDIR', dirname(__DIR__).'/web/');
21+
define('PROJECTDIR', dirname(__DIR__));
22+
define('FRONTENDTHEMEDIR', dirname(__DIR__).'/Themes');
23+
define('PUBLICPATH', '');
24+
25+
return $loader;

app/config/config.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
$db = array_merge(['port' => 3306], parse_url(getenv(getenv('DATABASE_URL_NAME') ?: 'DATABASE_URL')));
4+
5+
return array_replace_recursive($this->loadConfig($this->AppPath() . 'Configs/Default.php'), [
6+
7+
'db' => [
8+
'username' => $db['user'],
9+
'password' => $db['pass'],
10+
'dbname' => substr($db['path'], 1),
11+
'host' => $db['host'],
12+
],
13+
14+
'phpSettings' => [
15+
'display_errors' => 1
16+
],
17+
18+
'front' => array(
19+
'showException' => true,
20+
'throwExceptions' => false,
21+
),
22+
23+
'plugin_directories' => [
24+
'Default' => $this->AppPath('Plugins_' . 'Default'),
25+
'Local' => PROJECTDIR . '/Plugins/Local/',
26+
'Community' => PROJECTDIR . '/Plugins/Community/',
27+
],
28+
]);
29+

app/create_symlinks.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env bash
2+
set -o nounset
3+
set -o errexit
4+
set -o pipefail
5+
6+
# Set magic variables for current FILE & DIR
7+
declare -r __FILE__=$(readlink -f ${BASH_SOURCE[0]})
8+
declare -r __DIR__=$(dirname $__FILE__)
9+
10+
cd $__DIR__/..
11+
echo "Create symlinks in $__DIR__"
12+
13+
rm -rf web/themes/Backend/ExtJs/backend
14+
mkdir -p web/themes/Backend/ExtJs/backend
15+
ln -s ../../../../../vendor/shopware/shopware/themes/Backend/ExtJs/backend/_resources web/themes/Backend/ExtJs/backend/_resources
16+
17+
rm -rf web/engine/Library
18+
mkdir -p web/engine/Library
19+
ln -s ../../../vendor/shopware/shopware/engine/Library/CodeMirror web/engine/Library/CodeMirror
20+
ln -s ../../../vendor/shopware/shopware/engine/Library/ExtJs web/engine/Library/ExtJs
21+
ln -s ../../../vendor/shopware/shopware/engine/Library/TinyMce web/engine/Library/TinyMce
22+
23+
rm -rf web/themes/Frontend/Responsive/frontend/
24+
mkdir -p web/themes/Frontend/Responsive/frontend/
25+
ln -s ../../../../../vendor/shopware/shopware/themes/Frontend/Responsive/frontend/_public web/themes/Frontend/Responsive/frontend/_public

app/install.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/usr/bin/env bash
2+
set -o nounset
3+
set -o errexit
4+
set -o pipefail
5+
6+
# Set magic variables for current FILE & DIR
7+
declare -r __FILE__=$(readlink -f ${BASH_SOURCE[0]})
8+
declare -r __DIR__=$(dirname $__FILE__)
9+
10+
# Source .env file
11+
if [ -f $__DIR__/../.env ]; then
12+
echo Found .env
13+
source $__DIR__/../.env
14+
fi
15+
16+
$__DIR__/../bin/console sw:cache:clear
17+
18+
$__DIR__/../bin/console sw:database:setup --steps=drop,create,import
19+
20+
if [ $IMPORT_DEMODATA = true ] ; then
21+
$__DIR__/../bin/console sw:database:setup --steps=importDemodata
22+
fi
23+
24+
$__DIR__/../bin/console sw:database:setup --steps=setupShop --shop-url="$SHOP_URL"
25+
26+
$__DIR__/../bin/console sw:snippets:to:db --include-plugins
27+
28+
$__DIR__/../bin/console sw:theme:initialize
29+
30+
$__DIR__/../bin/console sw:firstrunwizard:disable
31+
32+
$__DIR__/../bin/console sw:admin:create --name="$ADMIN_NAME" --email="$ADMIN_EMAIL" --username="$ADMIN_USERNAME" --password="$ADMIN_PASSWORD" -n
33+
34+
$__DIR__/create_symlinks.sh
35+

app/services.xml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<container xmlns="http://symfony.com/schema/dic/services"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
5+
6+
<services>
7+
<service id="monolog.handler.rotating_file" class="Monolog\Handler\RotatingFileHandler" public="false">
8+
<argument>%kernel.logs_dir%/core_%kernel.environment%.log</argument>
9+
<argument>14</argument>
10+
<call method="pushProcessor">
11+
<argument type="service" id="monolog.processor.uid" />
12+
</call>
13+
</service>
14+
15+
<service id="myproject" decorates="monolog.handler.main" class="Monolog\Handler\StreamHandler">
16+
<argument type="string">php://stderr</argument>
17+
</service>
18+
19+
20+
</services>
21+
</container>

app/update.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env bash
2+
set -o nounset
3+
set -o errexit
4+
set -o pipefail
5+
6+
# Set magic variables for current FILE & DIR
7+
declare -r __FILE__=$(readlink -f ${BASH_SOURCE[0]})
8+
declare -r __DIR__=$(dirname $__FILE__)
9+
10+
# Source .env file
11+
if [ -f $__DIR__/../.env ]; then
12+
echo Found .env
13+
source $__DIR__/../.env
14+
fi
15+
16+
17+
$__DIR__/../bin/console sw:migrations:migrate --mode=update || true
18+
19+
$__DIR__/create_symlinks.sh
20+

bin/console

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
set_time_limit(0);
5+
6+
require_once __DIR__.'/../app/autoload.php';
7+
8+
use Shopware\Components\Console\Application;
9+
use Symfony\Component\Console\Input\ArgvInput;
10+
11+
$input = new ArgvInput();
12+
$env = $input->getParameterOption(array('--env', '-e'), getenv('SHOPWARE_ENV'));
13+
14+
$kernel = new AppKernel($env, false);
15+
$application = new Application($kernel);
16+
$application->run($input);

composer.json

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
"name": "bcremer/shopware-composer-project",
3+
"description": "Project template for Shopware projects with composer",
4+
"type": "project",
5+
"license": "MIT",
6+
"authors": [
7+
{
8+
"name": "Benjamin Cremer",
9+
"email": "[email protected]"
10+
}
11+
],
12+
"autoload": {
13+
"psr-4": { "": "src/" },
14+
"classmap": [ "app/AppKernel.php" ]
15+
},
16+
"repositories": [
17+
{
18+
"type": "vcs",
19+
"url": "https://github.com/bcremer/shopware"
20+
}
21+
],
22+
"require": {
23+
"php": "^5.6.4||^7.0",
24+
"ext-apcu": "*",
25+
"shopware/shopware": "dev-composer-project",
26+
"composer/installers": "^1.0",
27+
"vlucas/phpdotenv": "~2.0"
28+
},
29+
"extra": {
30+
"installer-paths": {
31+
"Plugins/Local/Backend/{$name}/": ["type:shopware-backend-plugin"],
32+
"Plugins/Local/Core/{$name}/": ["type:shopware-core-plugin"],
33+
"Plugins/Local/Frontend/{$name}/": ["type:shopware-frontend-plugin"]
34+
}
35+
},
36+
"config": {
37+
"optimize-autoloader": true
38+
},
39+
"scripts": {
40+
"post-root-package-install": [
41+
"php -r \"copy('.env.example', '.env');\""
42+
],
43+
"post-install-cmd": [
44+
"app/update.sh"
45+
]
46+
}
47+
}

0 commit comments

Comments
 (0)