├── .editorconfig ├── .gitignore ├── .php_cs.dist ├── .travis.yml ├── CHANGELOG.md ├── Commands └── PurifyCssCommand.php ├── Components ├── PurifyCss.php └── Theme │ └── Compiler.php ├── FroshPerformance.php ├── ISSUE_TEMPLATE.md ├── LICENCE.md ├── README.md ├── Resources ├── services.xml ├── services │ └── theme.xml └── store │ ├── de.html │ ├── en.html │ └── images │ ├── 0.png │ └── 1.png ├── build.sh ├── composer.json ├── plugin.png └── plugin.xml /.editorconfig: -------------------------------------------------------------------------------- 1 | # Shopware 5 editor configuration normalization 2 | # http://editorconfig.org/ 3 | 4 | # This is the top-most .editorconfig file; do not search in parent directories. 5 | root = true 6 | 7 | # All files. 8 | [*] 9 | end_of_line = lf 10 | indent_style = space 11 | indent_size = 4 12 | charset = utf-8 13 | trim_trailing_whitespace = true 14 | insert_final_newline = true 15 | 16 | [*.md] 17 | trim_trailing_whitespace = false 18 | 19 | [*.ini] 20 | insert_final_newline = false 21 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | vendor -------------------------------------------------------------------------------- /.php_cs.dist: -------------------------------------------------------------------------------- 1 | in(__DIR__); 3 | 4 | return PhpCsFixer\Config::create() 5 | ->setUsingCache(false) 6 | ->setRules( 7 | [ 8 | '@PSR2' => true, 9 | '@Symfony' => true, 10 | 'no_useless_else' => true, 11 | 'no_useless_return' => true, 12 | 'ordered_class_elements' => true, 13 | 'ordered_imports' => true, 14 | 'phpdoc_order' => true, 15 | 'phpdoc_summary' => false, 16 | 'blank_line_after_opening_tag' => false, 17 | 'concat_space' => ['spacing' => 'one'], 18 | 'array_syntax' => ['syntax' => 'short'], 19 | 'yoda_style' => ['equal' => false, 'identical' => false, 'less_and_greater' => false], 20 | 'binary_operator_spaces' => ['default' => null], 21 | ] 22 | ) 23 | ->setFinder($finder); 24 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: php 2 | 3 | php: 4 | - 7.3 5 | 6 | sudo: false 7 | 8 | services: 9 | - mysql 10 | 11 | env: 12 | matrix: 13 | - SHOPWARE_VERSION="5.6" 14 | global: 15 | - PLUGIN_NAME=FroshPerformance 16 | - SHOPWARE_DIRECTORY="${HOME}/shopware" 17 | - PLUGIN_DIRECTORY="${SHOPWARE_DIRECTORY}/custom/plugins" 18 | 19 | cache: 20 | directories: 21 | - "${HOME}/.composer/cache/files" 22 | 23 | install: 24 | - composer install 25 | 26 | before_script: 27 | - mysql -e 'CREATE DATABASE shopware;' 28 | - if [[ "$(php --version | grep -cim1 xdebug)" -ge 1 ]]; then phpenv config-rm xdebug.ini; fi 29 | - git clone https://github.com/shopware/shopware.git ${SHOPWARE_DIRECTORY} --branch ${SHOPWARE_VERSION} 30 | - ant -f ${SHOPWARE_DIRECTORY}/build/build.xml -Dapp.host=localhost -Ddb.user=travis -Ddb.host=127.0.0.1 -Ddb.name=shopware build-unit 31 | - mv ${TRAVIS_BUILD_DIR} ${PLUGIN_DIRECTORY}/${PLUGIN_NAME} 32 | - php ${HOME}/shopware/bin/console sw:plugin:refresh 33 | - php ${HOME}/shopware/bin/console sw:plugin:install ${PLUGIN_NAME} 34 | - php ${HOME}/shopware/bin/console sw:plugin:activate ${PLUGIN_NAME} 35 | - cd ${PLUGIN_DIRECTORY}/${PLUGIN_NAME} 36 | 37 | script: 38 | - echo 'Noop' 39 | 40 | stages: 41 | - test 42 | - name: Store-Check 43 | if: branch = master 44 | - name: Store-Sync 45 | if: branch = master 46 | - name: Store-Deploy 47 | if: tag IS present 48 | 49 | jobs: 50 | include: 51 | - stage: Store-Check 52 | php: 7.3 53 | before_script: skip 54 | install: 55 | - ./build.sh master 56 | - wget 'https://github.com/FriendsOfShopware/FroshPluginUploader/releases/download/0.2.1/frosh-plugin-upload.phar' -O frosh-plugin-upload.phar 57 | script: 58 | - php frosh-plugin-upload.phar plugin:validate ${TRAVIS_BUILD_DIR}/${PLUGIN_NAME}*.zip 59 | - stage: Store-Sync 60 | before_script: skip 61 | php: 7.3 62 | install: 63 | - wget 'https://github.com/FriendsOfShopware/FroshPluginUploader/releases/download/0.2.1/frosh-plugin-upload.phar' -O frosh-plugin-upload.phar 64 | script: 65 | - php frosh-plugin-upload.phar plugin:update ${TRAVIS_BUILD_DIR} 66 | - stage: Store-Deploy 67 | before_script: skip 68 | php: 7.3 69 | install: 70 | - wget 'https://github.com/FriendsOfShopware/FroshPluginUploader/releases/download/0.2.1/frosh-plugin-upload.phar' -O frosh-plugin-upload.phar 71 | script: 72 | - ./build.sh 73 | - php frosh-plugin-upload.phar plugin:upload ${TRAVIS_BUILD_DIR}/${PLUGIN_NAME}*.zip 74 | 75 | deploy: 76 | skip_cleanup: true 77 | provider: releases 78 | api_key: 79 | secure: mBFlA3R3dj3SyR9bFXHyciINfTV6J7rhmtDh6QGG6WerrcJqKmwvHlSndoie7JhwpBjwxKIgBqfh/FnsP98pUN+6kzzY+aBUOZAe/uFgLGOe/PRML4C0SQPSFk+ZTUDTBSmSJYG6kz0xHg+zaBpPueInnT21smY8sT9gNb2UQzF7iFHnFMt5rtfLU9pJsIT4x3gkKFVZ84hNCaAFlsrxWWSiXXbaokpAwv1wP8bkyuz8gkaNm0gWGJnlQ7NSNxe/LyBEpmL4wRReC/tWLy0UqgVFoPF9HXxfYycaEuabwICmc6NBXJPimOHxZ+FMb0UXuoIWbgy4AsBDH4y2aUpyrugHsEdMLyT/tp42N0zDCwNQ6PwPmSoyHB2P8WU8wH0l3F+O46j44oyxmxJ4u71Di9HTgBqYD6ZJNO8PBkT/k1E7G6vrJ0tz/Vze5SO1mKvFrFFOXypkZD6/y664abopt92iWHXTNRJH1A5CFooSxEGYLhiKI4K8DC+jHHfICdbGKBeX6oPp4EbQxCoaETNbUcytVS/kxWfNmPNNNhRADBc/4/JCRtLhDJ7UTi2BIQ6atcuLWdPaTFW+SFuYkU442C6v3mlyCo3vskl+AYX6+Ntq6r00Sp7+8IzKhgbPIHqnIl0b48geKOxVKowZ3SXlTnP6P4B30+RqQSbUTodO9b8= 80 | file: FroshPerformance*.zip 81 | file_glob: true 82 | on: 83 | repo: FriendsOfShopware/FroshPerformance 84 | tags: true 85 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## 1.0.0 (2018-02-15) 4 | 5 | **Implemented enhancements:** 6 | 7 | - 8 | 9 | **Closed issues:** 10 | 11 | - 12 | 13 | **Merged pull requests:** 14 | 15 | - 16 | -------------------------------------------------------------------------------- /Commands/PurifyCssCommand.php: -------------------------------------------------------------------------------- 1 | container->get('frosh_performance.components.purify_css'); 16 | $io = new SymfonyStyle($input, $output); 17 | 18 | if (!$purify->isRunnable()) { 19 | $io->error('Please install first purify-css'); 20 | exit(1); 21 | } 22 | 23 | list($before, $after) = $this->container->get('frosh_performance.components.purify_css')->purify($input->getArgument('shopId')); 24 | 25 | $io->success(sprintf('Purified css from %s to %s', $this->humanFilesize($before), $this->humanFilesize($after))); 26 | } 27 | 28 | protected function configure() 29 | { 30 | $this 31 | ->setName('frosh:purify:css') 32 | ->setDescription('Removes unused css styles') 33 | ->addArgument('shopId', InputArgument::OPTIONAL, 'Shop id', 1); 34 | } 35 | 36 | private function humanFilesize($bytes, $decimals = 2) 37 | { 38 | $sz = 'BKMGTP'; 39 | $factor = floor((strlen($bytes) - 1) / 3); 40 | 41 | return sprintf("%.{$decimals}f", $bytes / pow(1024, $factor)) . @$sz[$factor]; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Components/PurifyCss.php: -------------------------------------------------------------------------------- 1 | kernelRootDir = rtrim($kernelRootDir, '/'); 45 | $this->timestampPersistor = $timestampPersistor; 46 | $this->pathResolver = $pathResolver; 47 | $this->manager = $manager; 48 | } 49 | 50 | /** 51 | * @return bool 52 | */ 53 | public function isRunnable() 54 | { 55 | $finder = new ExecutableFinder(); 56 | 57 | return (bool) $finder->find('purifycss'); 58 | } 59 | 60 | /** 61 | * @param int $shopId 62 | * 63 | * @return array 64 | */ 65 | public function purify($shopId) 66 | { 67 | $finder = new ExecutableFinder(); 68 | $timestamp = $this->timestampPersistor->getCurrentTimestamp($shopId); 69 | 70 | $shop = $this->manager->find(Shop::class, $shopId); 71 | 72 | if (!$shop) { 73 | throw new \RuntimeException(sprintf('Shop with id %d does not exist', $shopId)); 74 | } 75 | 76 | $fileName = $this->pathResolver->buildTimestampName($timestamp, $shop, 'css'); 77 | $filePath = $this->kernelRootDir . '/web/cache/' . $fileName; 78 | 79 | $beforeSize = filesize($filePath); 80 | 81 | $arguments = [ 82 | $this->kernelRootDir . '/themes/**/*.js', 83 | $this->kernelRootDir . '/themes/**/*.tpl', 84 | $this->kernelRootDir . '/custom/**/*.js', 85 | $this->kernelRootDir . '/custom/**/*.tpl', 86 | $this->kernelRootDir . '/engine/Shopware/Plugins/**/*.tpl', 87 | $this->kernelRootDir . '/engine/Shopware/Plugins/**/*.js', 88 | '-m', 89 | ]; 90 | 91 | array_unshift($arguments, $filePath); 92 | array_unshift($arguments, $finder->find('purifycss')); 93 | array_unshift($arguments, $finder->find('node')); 94 | 95 | $arguments[] = '-o'; 96 | $arguments[] = $filePath; 97 | 98 | $process = new Process($arguments); 99 | $process->run(); 100 | 101 | if ($process->getExitCode()) { 102 | throw new \RuntimeException(sprintf('Purify failed with message %s and code %d', $process->getErrorOutput(), $process->getExitCode())); 103 | } 104 | 105 | $afterSize = filesize($filePath); 106 | 107 | return [$beforeSize, $afterSize]; 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /Components/Theme/Compiler.php: -------------------------------------------------------------------------------- 1 | shopwareRoot = $rootDir; 65 | $this->resolver = $pathResolver; 66 | parent::__construct($rootDir, $compiler, $pathResolver, $inheritance, $service, $jsCompressor, $eventManager, $timestampPersistor, $releaseStruct); 67 | $this->pluginConfig = $pluginConfig; 68 | } 69 | 70 | /** 71 | * @param Shop\Shop $shop 72 | * @param int $timestamp 73 | */ 74 | public function createThemeTimestamp(Shop\Shop $shop, $timestamp) 75 | { 76 | if ($this->pluginConfig['removeShopwareRevisionFromFont']) { 77 | $fileName = $this->resolver->buildTimestampName($timestamp, $shop, 'css'); 78 | $path = $this->shopwareRoot . '/web/cache/' . $fileName; 79 | 80 | $invalidQuerys = [ 81 | '?' . Shopware()->Config()->revision, 82 | '?#' . Shopware()->Config()->revision, 83 | ]; 84 | 85 | if (file_exists($path)) { 86 | file_put_contents($path, str_replace($invalidQuerys, '', file_get_contents($path))); 87 | } 88 | } 89 | 90 | parent::createThemeTimestamp($shop, $timestamp); 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /FroshPerformance.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | %frosh_performance.plugin_dir%/Resources/views 9 | %frosh_performance.plugin_dir%/Resources/smarty 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | %shopware.app.rootdir% 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /Resources/services/theme.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | 9 | %shopware.app.rootdir% 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /Resources/store/de.html: -------------------------------------------------------------------------------- 1 |
Performance Optimierungen für Shopware
2 |

3 |

Features

4 | 11 |

12 |
13 |

Purify-CSS Integration

14 |

15 | Für Purify-CSS wird NodeJS gebraucht. Purify-CSS muss auch global installiert sein. 16 | Der Prozess kann mit den Befehl ./bin/console frosh:purify:css ausgeführt werden 17 |

18 |
19 | 20 |
21 |
Das Plugin wird von der Github Organization FriendsOfShopware entwickelt. 23 | Maintainer des Plugins ist: Soner Sayakci
24 |
Das Github Repository ist zu finden hier 25 |
26 |
Bei Fragen / Fehlern bitte ein 27 | Github Issue erstellen
28 |
29 |
-------------------------------------------------------------------------------- /Resources/store/en.html: -------------------------------------------------------------------------------- 1 |
Performance Improvments for Shopware
2 |

3 |

Features

4 | 11 |
12 |

Purify-CSS Integration

13 |

14 | You need for Purify-CSS nodejs, also purify-css must be installed globally 15 | The process can be started with ./bin/console frosh:purify:css 16 |

17 |
18 |
19 |
This plugin is part of the Github Organization FriendsOfShopware . Maintainer 21 | from the plugin is: Soner Sayakci
22 |
You can find the Github repository here
24 |
For questions or bugs please create 25 | a Github Issue
26 |
27 |
-------------------------------------------------------------------------------- /Resources/store/images/0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FriendsOfShopware/FroshPerformance/0bc41f9468140bc2188237de3b469778275cddf6/Resources/store/images/0.png -------------------------------------------------------------------------------- /Resources/store/images/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FriendsOfShopware/FroshPerformance/0bc41f9468140bc2188237de3b469778275cddf6/Resources/store/images/1.png -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | commit=$1 4 | if [ -z ${commit} ]; then 5 | commit=$(git tag --sort=-creatordate | head -1) 6 | if [ -z ${commit} ]; then 7 | commit="master"; 8 | fi 9 | fi 10 | 11 | # Remove old release 12 | rm -rf FroshPerformance FroshPerformance-*.zip 13 | 14 | # Build new release 15 | mkdir -p FroshPerformance 16 | git archive ${commit} | tar -x -C FroshPerformance 17 | composer install --no-dev -n -o -d FroshPerformance 18 | ( find ./FroshPerformance -type d -name ".git" && find ./FroshPerformance -name ".gitignore" && find ./FroshPerformance -name ".gitmodules" ) | xargs rm -r 19 | zip -r FroshPerformance-${commit}.zip FroshPerformance 20 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "frosh/performance", 3 | "keywords": ["shopware", "performance", "minify", "http2"], 4 | "description": "Performance improvements for Shopware", 5 | "license": "MIT", 6 | "type": "shopware-plugin", 7 | "extra": { 8 | "installer-name": "FroshPerformance" 9 | }, 10 | "require": { 11 | "composer/installers": "~1.0" 12 | }, 13 | "suggest": { 14 | "frosh/webp": "Allows to generate thumbnails in webp" 15 | }, 16 | "scripts": { 17 | "test": "phpunit -c tests/ --colors=always" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /plugin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FriendsOfShopware/FroshPerformance/0bc41f9468140bc2188237de3b469778275cddf6/plugin.png -------------------------------------------------------------------------------- /plugin.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 1.1.0 7 | Friends of Shopware 8 | MIT 9 | https://friendsofshopware.github.io/ 10 | Friends of Shopware 11 | 12 | Minify HTML output, Allow pushing resources using HTTP2 Push 13 | Komprimiert HTML, erlaubt die Nutzung mit HTTP2 Push 14 | 15 | 16 | Compability to Shopware 5.6 17 | Kompatiblität zu Shopware 5.6 hergestellt 18 | 19 | 20 | 21 | Increased compability with Payment Provider Wirecard 22 | Support Verbessert mit Zahlungsanbieter Wirecard 23 | 24 | 25 | 26 | Fixed CachedConfigReader with subshops, Sitemap and Robots.txt will be not more minify 27 | CachedConfigReader behoben mit Subshops, Sitemap und Robots.txt wird nicht mehr minifiziert 28 | 29 | 30 | 31 | Fixed compatibility to plugin DneCustomJsCss 32 | Kompatiblität zu DneCustomJsCss verbessert 33 | 34 | 35 | 36 | Improved compatibility with plugins and themes 37 | Kompatiblität mit Plugins und Themes verbessert 38 | 39 | 40 | --------------------------------------------------------------------------------