{"id":18553713,"url":"https://github.com/websemantics/pyrocms-cheatsheet","last_synced_at":"2025-04-09T23:30:50.571Z","repository":{"id":150921734,"uuid":"42437096","full_name":"websemantics/pyrocms-cheatsheet","owner":"websemantics","description":"A list of commands and features for PyroCMS 3.","archived":false,"fork":false,"pushed_at":"2017-03-21T18:45:23.000Z","size":45798,"stargazers_count":32,"open_issues_count":0,"forks_count":4,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-31T20:38:05.876Z","etag":null,"topics":["cheatsheet","pyrocms","pyrocms3"],"latest_commit_sha":null,"homepage":"http://websemantics.github.io/pyrocms-cheatsheet","language":"CSS","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/websemantics.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2015-09-14T08:39:24.000Z","updated_at":"2021-06-09T14:55:31.000Z","dependencies_parsed_at":"2023-04-09T04:33:05.526Z","dependency_job_id":null,"html_url":"https://github.com/websemantics/pyrocms-cheatsheet","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/websemantics%2Fpyrocms-cheatsheet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/websemantics%2Fpyrocms-cheatsheet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/websemantics%2Fpyrocms-cheatsheet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/websemantics%2Fpyrocms-cheatsheet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/websemantics","download_url":"https://codeload.github.com/websemantics/pyrocms-cheatsheet/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248129534,"owners_count":21052589,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cheatsheet","pyrocms","pyrocms3"],"created_at":"2024-11-06T21:18:04.575Z","updated_at":"2025-04-09T23:30:48.750Z","avatar_url":"https://github.com/websemantics.png","language":"CSS","funding_links":[],"categories":[],"sub_categories":[],"readme":"```                         \n\n                                                               +\n                                                               /\\\n                                                              //:\\\n                                                             //\\\\\\\\                        _\n                                                            ///\\\\\\'\\                      /,\\_\n                                                    +      /// \\\\\\\\\\\\                    (____)\n                                                    /\\    //''//\\\\ \\.\\                   (\n   __   __   __   __                               //\\\\  /// ///\\\\\\\\\\\\\\                 /\n  |: | |''| |' | |  |                             ///\\\\\\//////.|. \\\\ .\\\\               '\n  |                 |                            ///;:\\\\\\\\\\\\///.|.\\\\\\\\ \\:\\\n  |:                :                             |:    |//////||\\\\\\:\\\\\\\\'\\\n  |:   . .          | \\    __  __  __     __   _  |:    ://;//,..';\\\\'\\\\\\\\\\\\\n   \\  - - ----- -  /   |__|' ||: ||  |_ _|  :_: |_|                     |\n    | --- - -     |                               |              [ ]   :|\n    |:                                            |    --- - -         :|  __   __   __   __   __   __  \n_ _ :                                                                   |_|: | /: | |  | |: | |  \\.|' |_\n    |            ____ _ _ _   __ _ ___     ___ _ _   _____ _ _ __       |\n    |           | ,         \\ \\  '    \\   /  ' ' /  |:           \\\\     :                   |\n    |                ,-.     | \\       \\ /      /   |    ,-.      |                         |\n                |    |__)    |  \\\\      V      /    |    |__)     |\n                |:      ____/    \\            /     |:           \u003c                __       .\n    |           |      ||         |:         |      |:     |\\     \\              /  |     / \\\n                |       |         |   ['_]:  |      |      | \\     \\     |\\     |    \\_,-/   |\n    :           |_ _  __|         |_ _ ____. |      |  __ _|  \\ ____\\    | ` __  \\    (      /\n                                                                          \\/   \\  ''-.  `__,'\n    |             |                                                       /    /      \\    \\\n    |                   (           (                      )              |   |        |   |\n    |             (          )          )      )         (                \\    \\      /    /\n                 ____) _ ___  __ _____ (___  _  _ ___ ___ _____            \\    `-..-'    /\n                / _/ || | __|/  \\_   _/' _/| || | __| __|_   _|   \u003c------\\  '-_   __ / __  \\\n               | \\_| \u003e\u003c | _|| /\\ || | `._`.| \u003e\u003c | _|| _|  | |      \u003c------+===())))==)  ) /===========\n                \\__/_||_|___|_||_||_| |___/|_||_|___|___| |_|     \u003c------/    `--' `.__,'\n\n\n          ⎯ ⎯⎯ ⎯⎯⎯⎯⎯ ∈   A list of commands and features for PyroCMS 3 ⎯⎯⎯⎯⎯⎯ ⎯⎯ ⎯\n\n```              \n\u003e This document has the full list of commands, code samples and best use practices for PyroCMS 3 development under different categories.\n\n#### Try [Live App](http://websemantics.github.io/pyrocms-cheatsheet) for an enhanced user experience.\n\n## Table of Contents\n\n- [Cheatsheets](#cheatsheets)\n  - [Installation](#installation)\n  - [Configuration](#configuration)\n  - [Settings](#settings)\n  - [Artisan](#artisan)\n  - [Pyro Magic](#pyro-magic)\n  - [Views](#views)\n  - [Twig](#twig)\n- [Development](#development)\n  - [Install](#install)\n  - [Build](#build)\n  - [Watch](#watch)\n- [Related](#related)\n- [Contribution](#contribution)\n- [Credits](#credits)\n- [License](#license)\n\n## Cheatsheets\n\n### Installation\n\n```bash\n# Use 'create-project' command to install PyroCMS\ncomposer create-project pyrocms/pyrocms folder_name\n# Use '--prefer-source' flag for Windows environment\ncomposer create-project pyrocms/pyrocms --prefer-dist\n# Enable write permissions for some folders\nsudo chmod -R 777 path_to/pyrocms/storage\nsudo chmod -R 777 path_to/pyrocms/public/assets\nsudo chmod -R 777 path_to/pyrocms/bootstrap/cache\n# Or change PyroCMS folder ownership\nsudo chown -R user:admin path_to/pyrocms\n# Remove installer-module from composer.json then run,\ncomposer update\n```\n\n### Configuration\n\n```php\n// Overrid Streams configuration values at\npath_to/pyrocms/config/streams\n// Available config files for Streams located at\npath_to/pyrocms/vendor/anomaly/streams-platform\n/resources/config\n// Set application environment in .env, 'local'\n// 'staging' or 'production'\nAPP_ENV = local\n// Edit .env config file to enable debug mode\nAPP_DEBUG = true\n// Get current env variable in php\n$env = App::environment();\n$env = app()-\u003eenvironment();\n// Use config helper to access configuration values\n$value = config('app.locale');\n// Set configuration values through config helper\nconfig(['app.locale' =\u003e 'fr']);\n// Get core configuration values\n$value = config('streams::assets.paths');\n// Get Addon configuration, 'name' module\n$value = config('vendor.module.slug::name.key');\n```\n\n### Settings\n\n```php\n// To read a value from the settings module inject\n// Anomaly\\SettingsModule\\Setting\\Contract\\SettingRepositoryInterface\n// into your class method then read the require field\nfunction index(SettingRepositoryInterface $settings)\n{\n    $val = $settings-\u003evalue(\n    'vendor.module.slug::field_name','default'));\n}\n```\n\n### Artisan\n\n```bash\n# Cache all configuration files into a single file\nphp artisan config:cache\n# Turn-on maintenance mode\nphp artisan down\n# Turn-off maintenance mode\nphp artisan up\n# Set application key\nphp artisan key:generate\n\n# ********* CACHE *********\n\n# Clear compiled assets cache\nphp artisan assets:clear\n# Clear views cache\nphp artisan view:clear\n# Clear twig cache\nphp artisan twig:clean\n# Clear streams entry models\nphp artisan streams:cleanup\n# Clear the route cache file\nphp artisan route:clear\n# Clear http cache\nphp artisan httpcache:clear\n# Clear missing files from files table\nphp artisan files:clean\n# Clear debug storage\nphp artisan debugbar:clear\n# Clear configuration cache\nphp artisan config:clear\n# Clear application cache\nphp artisan cache:clear\n# Clear application cache\nphp artisan cache:clear\n# Clear expired password rest tokens\nphp artisan auth:clear-resets\n# Clear compiled class file\nphp artisan clear-compiled\n\n# ********* STREAMS *********\n\n# Create a stream migration (fields or stream)\nphp artisan make:migration create_stream_fields\n--addon=vendor.module.slug\n\n# ********* ADDONS *********\n\n# Create a theme\nphp artisan make:addon vendor.theme.slug\n# Create a share module\nphp artisan make:addon vendor.module.slug --shared\n# Create a plugin\nphp artisan make:addon vendor.plugin.slug\n\n# ********* MODULES *********\n\n# Install, uninstall and reinstall a module\nphp artisan module:install vendor.module.slug\nphp artisan module:uninstall vendor.module.slug\nphp artisan module:reinstall vendor.module.slug\n# Seed a module streams\nphp artisan db:seed --addon=vendor.module.slug\n\n# ********* MIGRATION *********\n\n# Manage migrations manually\nphp artisan migrate --addon=vendor.module.slug\nphp artisan migrate:reset --addon=vendor.module.slug\nphp artisan migrate:refresh --addon=vendor.module.slug\n```\n\n### Pyro Magic\n\n```bash\n#Your own Builder, add to bindings in service provider\nprotected $bindings = [\n    'login' =\u003e 'Vendor\\CoolNameModule\\Your\\Namespace\\LoginFormBuilder',\n];\n#Render with\n{{ form('login') }}\n\n#Form based on Streams (no builder required)\n{{ form({'stream': slug, 'namespace': farts}).buttons(['cancel']).redirect('foo/bar').successMessage('You are da winner!') }}\n```\n\n### Views\n\n```php\n// Return a view using 'view' helper function.\n// Views are location at: path_to/pyrocms/addons/\n// shared/vendor/name-module/resources/views\nreturn view('vendor.module.slug::page',\n['title' =\u003e 'app']);\n// Return a view from nested folder 'admin'\nreturn view('vendor.module.slug::admin.page', []);\n// Check if a view exists\nif (view()-\u003eexists('vendor.module.slug::page')) {}\n// Return a view from active theme\nreturn view('theme::page', $data);\n// Return a view from active module\nreturn view('module::page', $data);\n// Passing $data as an array with key/value pairs\nreturn view('module::page', ['name','Jo']);\n// Passing individual key/value using 'with' method\nreturn view('module::page')-\u003ewith('name','Jo');\n// Share data with all views. Place in Service\n// Provider's 'boot' method\nview()-\u003eshare('key', 'value');\n// To override core pyro views, insert this in your\n// module's service provider. The example below will\n// override the user login form with a view in your\n// module's resources folder:\n// 'resources\\views\\users\\login.twig'\nprotected $overrides = [\n   'anomaly.module.users::login' =\u003e\n            'vendor.module.slug::core/users/login'\n];\n// Override the form view directly from plugin call\n{{ login_form({'options': {'form_view':\n'vendor.module.slug::streams/form/form'}}) }}\n```\n\n### Twig\n\n```php\n# Access addon properties\n{{ addon('settings').installed }}\n# Access config properties\n{{ config('vendor.module.name::filename.property') }}\n// Loop through files\n{% for file in entry.example %}\n    File {{ loop.index }} is a {{ file.mime_type }}.\n{% endfor %}\n// Insert image from the current theme\n{{ image_url('theme::img/image.png') }}\n// Embed a view partial\n{{ view(\"vendor.module.slug::partials/file\") }}\n// Granular control over forms; user login form\n// as an example which shows how to add custom\n// CSS classes to the form and input elements.\n{% set form = login_form() %}\n{{ form.open({'class' : 'ui form'}) |raw }}\n{% for field in form.fields %}\n \u0026lt;div class=\"field\"\u0026gt;\n  \u0026lt;label\u0026gt;{{ field.label|raw }}\u0026lt;/label\u0026gt;\n  {{ field.setClass('custom class').input|raw }}\n \u0026lt;/div\u0026gt;\n{% endfor %}\n{{ form.actions |raw }}\n{{ form.close() |raw }}\n```\n\n## Development\n\nIf you want to make code contribution, or use this code for your own project, here are some of the commands included in `package.json` to get you started.\n\nClone this repo and install node dependencies\n``` bash\nnpm install\n```\n\nBuild\n``` bash\nnpm run build\n```\n\nWatch\n``` bash\nnpm run watch\n```\n\n## Support\n\nNeed help or have a question? post at [StackOverflow](https://stackoverflow.com/questions/tagged/pyrocms-cheatsheet+pyrocms+websemantics).\n\n*Please don't use the issue trackers for support/questions.*\n\n*Star if you find this project useful, to show support or simply for being awesome :)*\n\n## Contribution\n\nThe [live app](http://websemantics.github.io/pyrocms-cheatsheet) was built to read and parse the markdown included in `README.md` and present it in a user-friendly manner.\n\nTo contribute suggestions, best practices and or code samples for PyroCMS developments, please edit `README.md` and create a pull request.\n\n## Related Projects\n\n- [PyroCMS](https://github.com/pyrocms/pyrocms), an MVC PHP Content Management System built to be easy to use, theme and develop with. It is used by individuals and organizations of all sizes around the world.\n- [PyroCMS Builder](https://github.com/websemantics/entity_builder-extension), scaffold your PyroCMS 3 apps in style for a more pleasurable and productive coding experience.\n- [Auto Pyro](https://github.com/websemantics/auto-pyro), a PyroCMS deploy tool for faster and more pleasurable development experience.\n- [Awesome PyroCMS](https://github.com/websemantics/awesome-pyrocms), a curated list of PyroCMS addons and resources.\n\n## Credits\n\nThis project was inspired by [Laravel5 Cheatsheet](https://github.com/summerblue/laravel5-cheatsheet)\n\n## License\n\n[MIT license](http://opensource.org/licenses/mit-license.php) Copyright (c) Web Semantics, Inc.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebsemantics%2Fpyrocms-cheatsheet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwebsemantics%2Fpyrocms-cheatsheet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebsemantics%2Fpyrocms-cheatsheet/lists"}