├── .gitignore ├── LICENSE ├── README.md ├── composer.json ├── config └── .gitkeep ├── core ├── console ├── server │ └── router.php └── src │ └── PatternLab │ └── Installer.php ├── public └── .gitkeep └── source └── .gitkeep /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | export/* 3 | public/* 4 | source/styleguide/* 5 | vendor/* 6 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Brad Frost, http://bradfrostweb.com & Dave Olsen, http://dmolsen.com 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![license](https://img.shields.io/github/license/pattern-lab/edition-php-twig-standard.svg) 2 | [![Packagist](https://img.shields.io/packagist/v/pattern-lab/edition-twig-standard.svg)](https://packagist.org/packages/pattern-lab/edition-mustache-webdesignday) [![Gitter](https://img.shields.io/gitter/room/pattern-lab/php.svg)](https://gitter.im/pattern-lab/php) 3 | 4 | # Pattern Lab Standard Edition for Twig 5 | 6 | The Standard Edition for Twig gives developers and designers a clean and stable base from which to develop a Twig-based pattern library. 7 | 8 | ## Packaged Components 9 | 10 | The Standard Edition for Twig comes with the following components: 11 | 12 | * `pattern-lab/core`: [GitHub](https://github.com/pattern-lab/patternlab-php-core), [Packagist](https://packagist.org/packages/pattern-lab/core) 13 | * `pattern-lab/patternengine-twig`: [documentation](https://github.com/pattern-lab/patternengine-php-twig#twig-patternengine-for-pattern-lab-php), [GitHub](https://github.com/pattern-lab/patternengine-php-twig), [Packagist](https://packagist.org/packages/pattern-lab/patternengine-twig) 14 | * `pattern-lab/styleguidekit-assets-default`: [GitHub](https://github.com/pattern-lab/styleguidekit-assets-default), [Packagist](https://packagist.org/packages/pattern-lab/styleguidekit-assets-default) 15 | * `pattern-lab/styleguidekit-twig-default`: [GitHub](https://github.com/pattern-lab/styleguidekit-twig-default), [Packagist](https://packagist.org/packages/pattern-lab/styleguidekit-twig-default) 16 | 17 | ## Installing 18 | 19 | There are two methods for downloading and installing the Standard Edition for Twig: 20 | 21 | * [Download a pre-built project](#download-a-pre-built-package) 22 | * [Use Composer to create a project](#use-composer-to-create-a-project) 23 | 24 | ### Download a pre-built project 25 | 26 | The fastest way to get started with the Standard Edition for Twig is to [download the pre-built version](https://github.com/pattern-lab/edition-php-twig-standard/releases) from the [releases page](https://github.com/pattern-lab/edition-php-twig-standard/releases). The pre-built project comes with the [Base StarterKit for Twig](https://github.com/pattern-lab/starterkit-twig-base) installed by default. 27 | 28 | **Please note:** Pattern Lab uses [Composer](https://getcomposer.org/) to manage project dependencies. To upgrade the Standard Edition for Twig or to install plug-ins you'll need to [install Composer](https://getcomposer.org/doc/00-intro.md#installation-linux-unix-osx). We recommend that you [install it globally](https://getcomposer.org/doc/00-intro.md#globally). 29 | 30 | ### Use Composer to create a project 31 | 32 | Pattern Lab uses [Composer](https://getcomposer.org/) to manage project dependencies. 33 | 34 | #### 1. Install Composer 35 | 36 | Please follow the directions for [installing Composer](https://getcomposer.org/doc/00-intro.md#installation-linux-unix-osx) on the Composer website. We recommend you [install it globally](https://getcomposer.org/doc/00-intro.md#globally). 37 | 38 | #### 2. Install the Standard Edition for Twig 39 | 40 | Use Composer's [`create-project` command](https://getcomposer.org/doc/03-cli.md#create-project) to install the Standard Edition for Twig into a location of your choosing. In Terminal type: 41 | 42 | cd install/location/ 43 | composer create-project pattern-lab/edition-twig-standard your-project-name && cd $_ 44 | 45 | This will install the Standard Edition for Twig into a directory called `your-project-name` in `install/location/`. During the set-up process you will be asked to install an appropriate StarterKit. You will be automatically dropped into the project directory after the process is finished. 46 | 47 | ## Updating Pattern Lab 48 | 49 | To update Pattern Lab please refer to each component's GitHub repository. The components are listed at the top of the README. 50 | 51 | ## Helpful Commands 52 | 53 | These are some helpful commands you can use on the command line for working with Pattern Lab. 54 | 55 | ### List all of the available commands 56 | 57 | To list all available commands type: 58 | 59 | php core/console --help 60 | 61 | To list the options for a particular command type: 62 | 63 | php core/console --help --[command] 64 | 65 | ### Generate Pattern Lab 66 | 67 | To generate the front-end for Pattern Lab type: 68 | 69 | php core/console --generate 70 | 71 | ### Watch for changes and re-generate Pattern Lab 72 | 73 | To watch for changes and re-generate the front-end for Pattern Lab type: 74 | 75 | php core/console --watch 76 | 77 | ### Start a server to view Pattern Lab 78 | 79 | You can use PHP's built-in web server to review your Pattern Lab project in a browser. In a seperate window type: 80 | 81 | php core/console --server 82 | 83 | Then open [http://localhost:8080](http://localhost:8080) in your browser. 84 | 85 | ### Install a StarterKit 86 | 87 | To install a near-empty StarterKit as a starting point for your project type: 88 | 89 | php core/console --starterkit --init 90 | 91 | To install a specific StarterKit from GitHub type: 92 | 93 | php core/console --starterkit --install 94 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "pattern-lab/edition-twig-standard", 3 | "description": "Standard Edition of Pattern Lab for Twig. Installs all Twig-related assets except for a StarterKit.", 4 | "keywords": ["pattern lab"], 5 | "homepage": "http://patternlab.io", 6 | "license": "MIT", 7 | "type": "project", 8 | "authors": [ 9 | { 10 | "name": "Dave Olsen", 11 | "email": "dmolsen@gmail.com", 12 | "homepage": "http://dmolsen.com", 13 | "role": "Lead Developer" 14 | } 15 | ], 16 | "support": { 17 | "issues": "https://github.com/pattern-lab/patternlab-php/issues", 18 | "wiki": "http://patternlab.io/docs/", 19 | "source": "https://github.com/pattern-lab/patternlab-php/releases" 20 | }, 21 | "autoload": { 22 | "psr-0": { 23 | "PatternLab": "core/src/" 24 | } 25 | }, 26 | "require": { 27 | "php": ">=5.4", 28 | "pattern-lab/core": "^2.0.0", 29 | "pattern-lab/patternengine-twig": "^2.0.0", 30 | "pattern-lab/styleguidekit-twig-default": "^3.0.0" 31 | }, 32 | "scripts": { 33 | "post-install-cmd": [ 34 | "PatternLab\\Installer::postInstallCmd" 35 | ], 36 | "post-update-cmd": [ 37 | "PatternLab\\Installer::postUpdateCmd" 38 | ], 39 | "post-root-package-install": [ 40 | "PatternLab\\Installer::setProjectInstall", 41 | "PatternLab\\Installer::getSuggestedStarterKits", 42 | "PatternLab\\Installer::getConfigOverrides" 43 | ], 44 | "post-package-install": [ 45 | "PatternLab\\Installer::postPackageInstall" 46 | ], 47 | "post-package-update": [ 48 | "PatternLab\\Installer::postPackageUpdate" 49 | ], 50 | "pre-package-uninstall": [ 51 | "PatternLab\\Installer::prePackageUninstall" 52 | ] 53 | }, 54 | "extra": { 55 | "patternlab": { 56 | "starterKitSuggestions": [ 57 | "pattern-lab/starterkit-twig-base", 58 | "pattern-lab/starterkit-twig-demo" 59 | ] 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /config/.gitkeep: -------------------------------------------------------------------------------- 1 | After you generate Pattern Lab for the first time your configuration file will be placed here. -------------------------------------------------------------------------------- /core/console: -------------------------------------------------------------------------------- 1 | dispatch("config.configLoadEnd"); 44 | 45 | // run the console 46 | Console::run(); 47 | -------------------------------------------------------------------------------- /core/server/router.php: -------------------------------------------------------------------------------- 1 | false, "packagesRemove" => false, "suggestedStarterKits" => array(), "configOverrides" => array(), "patternLabPackages" => array()); 22 | 23 | /** 24 | * Get any config overrides that may exist for the edition 25 | * @param {Object} a script event object from composer 26 | */ 27 | public static function getConfigOverrides(Event $event) { 28 | 29 | $extra = $event->getComposer()->getPackage()->getExtra(); 30 | if (isset($extra["patternlab"]) && isset($extra["patternlab"]["config"]) && is_array($extra["patternlab"]["config"])) { 31 | self::$installerInfo["configOverrides"] = $extra["patternlab"]["config"]; 32 | } 33 | 34 | } 35 | 36 | /** 37 | * Get the package info from each patternlab-* package's composer.json 38 | * @param {String} the type of event fired during the composer install 39 | * @param {Object} a script event object from composer 40 | */ 41 | public static function getPackageInfo($type, $event) { 42 | 43 | $package = ($type == "update") ? $event->getOperation()->getTargetPackage() : $event->getOperation()->getPackage(); 44 | $packageType = $package->getType(); 45 | $packageExtra = $package->getExtra(); 46 | $packageInfo = array(); 47 | 48 | // make sure we're only evaluating pattern lab packages 49 | if (strpos($packageType,"patternlab-") !== false) { 50 | 51 | $packageInfo["name"] = $package->getName(); 52 | $packageInfo["type"] = $packageType; 53 | $packageInfo["pathBase"] = $event->getComposer()->getInstallationManager()->getInstallPath($package); 54 | $packageInfo["pathDist"] = $packageInfo["pathBase"].DIRECTORY_SEPARATOR."dist".DIRECTORY_SEPARATOR; 55 | $packageInfo["extra"] = (isset($packageExtra["patternlab"])) ? $packageExtra["patternlab"] : array(); 56 | 57 | self::$installerInfo["packages"][] = $packageInfo; 58 | 59 | } 60 | 61 | } 62 | 63 | /** 64 | * Get the suggested starter kits from the root package composer.json 65 | * @param {Object} a script event object from composer 66 | */ 67 | public static function getSuggestedStarterKits(Event $event) { 68 | 69 | $extra = $event->getComposer()->getPackage()->getExtra(); 70 | if (isset($extra["patternlab"]) && isset($extra["patternlab"]["starterKitSuggestions"]) && is_array($extra["patternlab"]["starterKitSuggestions"])) { 71 | self::$installerInfo["suggestedStarterKits"] = $extra["patternlab"]["starterKitSuggestions"]; 72 | } 73 | 74 | } 75 | 76 | /** 77 | * Run the centralized postInstallCmd 78 | * @param {Object} a script event object from composer 79 | */ 80 | public static function postInstallCmd(Event $event) { 81 | 82 | InstallerUtil::postInstallCmd(self::$installerInfo, $event); 83 | 84 | } 85 | 86 | /** 87 | * Run the centralized postUpdateCmd 88 | * @param {Object} a script event object from composer 89 | */ 90 | public static function postUpdateCmd(Event $event) { 91 | 92 | InstallerUtil::postUpdateCmd(self::$installerInfo, $event); 93 | 94 | } 95 | 96 | /** 97 | * Clean-up when a package is removed 98 | * @param {Object} a script event object from composer 99 | */ 100 | public static function postPackageInstall(PackageEvent $event) { 101 | 102 | self::getPackageInfo("install", $event); 103 | 104 | } 105 | 106 | /** 107 | * Clean-up when a package is removed 108 | * @param {Object} a script event object from composer 109 | */ 110 | public static function postPackageUpdate(PackageEvent $event) { 111 | 112 | self::getPackageInfo("update", $event); 113 | 114 | } 115 | 116 | /** 117 | * Clean-up when a package is removed 118 | * @param {Object} a script event object from composer 119 | */ 120 | public static function prePackageUninstall(PackageEvent $event) { 121 | 122 | // make sure the postUpdateCmd doesnt actually do anything 123 | self::setPackagesRemove(); 124 | 125 | // get the basic package info 126 | $package = $event->getOperation()->getPackage(); 127 | $packageType = $package->getType(); 128 | $packageInfo = array(); 129 | 130 | // make sure we're only evaluating pattern lab packages. remove attributes related to them. 131 | if (strpos($packageType,"patternlab-") !== false) { 132 | 133 | $packageInfo["name"] = $package->getName(); 134 | $packageInfo["type"] = $packageType; 135 | $packageInfo["pathBase"] = $event->getComposer()->getInstallationManager()->getInstallPath($package); 136 | 137 | InstallerUtil::packageRemove($packageInfo); 138 | 139 | } 140 | 141 | } 142 | 143 | /** 144 | * Set the packages remove boolean to true 145 | */ 146 | public static function setPackagesRemove() { 147 | 148 | self::$installerInfo["packagesRemove"] = true; 149 | 150 | } 151 | 152 | /** 153 | * Set the project install boolean to true 154 | * @param {Object} a script event object from composer 155 | */ 156 | public static function setProjectInstall(Event $event) { 157 | 158 | self::$installerInfo["projectInstall"] = true; 159 | 160 | } 161 | 162 | } 163 | -------------------------------------------------------------------------------- /public/.gitkeep: -------------------------------------------------------------------------------- 1 | Holding file for public/ directory -------------------------------------------------------------------------------- /source/.gitkeep: -------------------------------------------------------------------------------- 1 | After you generate Pattern Lab for the first time your source files will be placed here. --------------------------------------------------------------------------------