forked from websemantics/pyrocms-cheatsheet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
290 lines (278 loc) · 11.2 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<meta property="og:title" content="PyroCMS 3 Cheat Sheet"/>
<meta property="og:url"
content="http://raw.githubusercontent.com/websemantics/pyrocms-cheatsheet/gh-pages/img/logo-1024.png"/>
<meta property="og:image"
content="http://raw.githubusercontent.com/websemantics/pyrocms-cheatsheet/gh-pages/img/logo-1024.png"/>
<meta property="og:image:secure_url"
content="https://raw.githubusercontent.com/websemantics/pyrocms-cheatsheet/gh-pages/img/logo-1024.png"/>
<meta property="og:image:type" content="image/png"/>
<meta property="og:image:width" content="1024"/>
<meta property="og:image:height" content="1024"/>
<link rel="icon" type="image/png" href="img/logo_red_48.png">
<title>PyroCMS 3 Cheat Sheet</title>
<script src="js/jquery.min.js"></script>
<script src="js/semantic.min.js"></script>
<script src="js/jquery.highlight.js"></script>
<script src="js/run_prettify.js"></script>
<script src="js/index.js"></script>
<link rel="stylesheet" type="text/css" href="css/semantic.min.css">
<link rel="stylesheet" type="text/css" href="css/index.css">
<script>
(function (i, s, o, g, r, a, m) {
i['GoogleAnalyticsObject'] = r;
i[r] = i[r] || function () {
(i[r].q = i[r].q || []).push(arguments)
}, i[r].l = 1 * new Date();
a = s.createElement(o),
m = s.getElementsByTagName(o)[0];
a.async = 1;
a.src = g;
m.parentNode.insertBefore(a, m)
})(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');
ga('create', 'UA-67748923-1', 'auto');
ga('send', 'pageview');
</script>
</head>
<body>
<div></div>
<div class="ui borderless main menu">
<div id="container" class="ui text container">
<div class="header item">
<img id="logo" class="logo" src="img/logo_black_48.png">
<img id="logo-inverted" class="logo" src="img/logo_white_48.png">
<h2>PyroCMS 3 Cheat Sheet</h2>
</div>
<div class="item">
<iframe src="https://ghbtns.com/github-btn.html?user=websemantics&repo=pyrocms-cheatsheet&type=star&count=true&size=large"
frameborder="0" scrolling="0" width="160px" height="30px"></iframe>
</div>
<div class="right menu">
<div class="item">
<div class="ui action input">
<input id="search-input" type="text" placeholder="Search...">
<button id="search-btn" class="ui icon button blue">
<i class="search icon"></i>
</button>
</div>
</div>
<a href="https://github.com/websemantics/pyrocms-cheatsheet" target="_blank"
class="ui right floated item"><i class="github icon"></i> Github</a>
<a href="https://www.pyrocms.com/docs/pyrocms/setup/installation" target="_blank"
class="ui right floated item">PyroCMS Docs</a>
<a href="http://cheats.jesse-obrien.ca/" target="_blank" class="ui right floated item">Laravel CS</a>
<div class="item">
<div class="inline field">
<div class="ui toggle checkbox">
<input type="checkbox" tabindex="0" class="hidden">
<label id="lights-label">Lights On</label>
</div>
</div>
</div>
</div>
</div>
</div>
<div id="container" class="ui container">
<div class="ui three column stackable grid">
<div class="column">
<h3 class="ui dividing header">Installation <i class="download icon"></i></h3>
<pre class="prettyprint lang-bsh">
# Use 'create-project' command to install PyroCMS
composer create-project pyrocms/pyrocms folder_name
# Use '--prefer-source' flag for Windows environment
composer create-project pyrocms/pyrocms --prefer-dist
# Enable write permissions for some folders
sudo chmod -R 777 path_to/pyrocms/storage
sudo chmod -R 777 path_to/pyrocms/public/assets
sudo chmod -R 777 path_to/pyrocms/bootstrap/cache
# Or change pyrocms folder ownership
sudo chown -R user:admin path_to/pyrocms
# Install Stream from command line
./artisan install:streams
</pre>
<h3 class="ui dividing header">Configuration <i class="configure icon"></i></h3>
<pre class="prettyprint lang-php">
// Overrid Streams Platform configuration values at
path_to/pyrocms/config/streams
// Available config files for Streams located at
path_to/pyrocms/vendor/anomaly/streams-platform
/resources/config
// Set application environment in .env, 'local'
// 'staging' or 'production'
APP_ENV = local
// Edit .env config file to enable debug mode
APP_DEBUG = true
// Get current env variable in php
$env = App::environment();
$env = app()->environment();
// Use config helper to access configuration values
$value = config('app.locale');
// Set configuration values through config helper
config(['app.locale' => 'fr']);
// Get core configuration values
$value = config('streams::assets.paths');
// Get Addon configuration, 'name' module
$value = config('vendor.module.slug::name.key');
</pre>
<h3 class="ui dividing header">Settings <i class="setting icon"></i></h3>
<pre class="prettyprint lang-php">
// To read a value from the settings module inject
// Anomaly\SettingsModule\Setting\Contract\SettingRepositoryInterface
// into your class method then read the require field
function index(SettingRepositoryInterface $settings)
{
$val = $settings->value(
'vendor.module.slug::field_name','default'));
}
</pre>
</div>
<div class="column">
<h3 class="ui dividing header">Artisan <i class="terminal icon"></i></h3>
<pre class="prettyprint lang-bsg">
# Combine all configuration files into a single file
php artisan config:cache
# Enable maintenance mode
php artisan down
# Disable maintenance mode
php artisan down
# Set application key
php artisan key:generate
</pre>
<h4>Cache</h4>
<pre class="prettyprint lang-bsg">
# Clear the cache for assets
php artisan asset:clear
# Clear the cache for views
php artisan view:clear
# Clear the cache for twig
php artisan twig:clean
</pre>
<h4>Streams</h4>
<pre class="prettyprint lang-bsg">
# Create a stream migration (fields or stream)
php artisan make:migration create_stream_fields
--addon=vendor.module.slug
</pre>
<h4>Addons</h4>
<pre class="prettyprint lang-bsg">
# Create a theme
php artisan make:addon vendor.theme.slug
# Create a shared theme
php artisan make:addon vendor.theme.slug --shared
# Create a plugin
php artisan make:addon vendor.plugin.slug
</pre>
<h4>Modules</h4>
<pre class="prettyprint lang-bsg">
# Create a module WITH the builder Extension, add '--shared' for shared
php artisan make:module vendor slug
</pre>
<pre class="prettyprint lang-bsg">
# Create a module WITHOUT Builder Extension, add '--shared' for shared
php artisan make:addon ventor.module.slug
</pre>
<pre class="prettyprint lang-bsg">
# Install, uninstall and reinstall a module
php artisan module:install vendor.module.slug
php artisan module:uninstall vendor.module.slug
php artisan module:reinstall vendor.module.slug
# Seed the module's streams / entities
php artisan db:seed --addon=vendor.module.slug
</pre>
<h4>Entities</h4>
<pre class="prettyprint lang-bsg">
# Create a stream entity. This will create a stream
# migratiom, and an entity folder inside the addon's
# 'src' folder.
php artisan make:stream stream_slug
ventor.addon_type.addon_slug
</pre>
<h4>Migration</h4>
<pre class="prettyprint lang-bsg">
# Manage migrations manually
php artisan migrate --addon=vendor.module.slug
php artisan migrate:reset --addon=vendor.module.slug
php artisan migrate:refresh --addon=vendor.module.slug
</pre>
<h3 class="ui dividing header">Pyro Magic <i class="terminal icon"></i></h3>
<h4>Forms</h4>
<pre class="prettyprint lang-bsg">
#Your own Builder, add to bindings in service provider
protected $bindings = [
'login' => 'Vendor\CoolNameModule\Your\Namespace\LoginFormBuilder',
];
#Render with
{{ form('login') }}
#Form based on Streams (no builder required)
{{ form({'stream': slug, 'namespace': farts}).buttons(['cancel']).redirect('foo/bar').successMessage('You are da winner!') }}
</pre>
</div>
<div class="column">
<h3 class="ui dividing header">Views <i class="file text outline icon"></i></h3>
<pre class="prettyprint lang-php">
// Return a view using 'view' helper function.
// Views are location at: path_to/pyrocms/addons/
// shared/vendor/name-module/resources/views
return view('vendor.module.slug::page',
['title' => 'app']);
// Return a view from nested folder 'admin'
return view('vendor.module.slug::admin.page', []);
// Check if a view exists
if (view()->exists('vendor.module.slug::page')) {}
// Return a view from active theme
return view('theme::page', $data);
// Return a view from active module
return view('module::page', $data);
// Passing $data as an array with key/value pairs
return view('module::page', ['name','Jo']);
// Passing individual key/value using 'with' method
return view('module::page')->with('name','Jo');
// Share data with all views. Place in Service
// Provider's 'boot' method
view()->share('key', 'value');
// To override core pyro views, insert this in your
// module's service provider. The example below will
// override the user login form with a view in your
// module's resources folder:
// 'resources\views\users\login.twig'
protected $overrides = [
'anomaly.module.users::login' =>
'vendor.module.slug::core/users/login'
];
// Override the form view directly from plugin call
{{ login_form({'options': {'form_view':
'vendor.module.slug::streams/form/form'}}) }}
</pre>
<h3 class="ui dividing header">Twig <i class="puzzle outline icon"></i></h3>
<pre class="prettyprint lang-php">
// Loop through files
{% for file in entry.example %}
File {{ loop.index }} is a {{ file.mime_type }}.
{% endfor %}
// Insert image from the current theme
{{ image_url('theme::img/image.png') }}
// Embed a view partial
{{ view("vendor.module.slug::partials/file") }}
// Granular control over forms; user login form
// as an example which shows how to add custom
// CSS classes to the form and input elements.
{% set form = login_form() %}
{{ form.open({'class' : 'ui form'}) |raw }}
{% for field in form.fields %}
<div class="field">
<label>{{ field.label|raw }}</label>
{{ field.setClass('custom class').input|raw }}
</div>
{% endfor %}
{{ form.actions |raw }}
{{ form.close() |raw }}
</pre>
</div>
</div>
</body>
</html>