ptero 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +30 -13
- data/lib/ptero/version.rb +1 -1
- data/ptero.gemspec +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 165c7c7850463518a58561f975ff4c863b628811
|
4
|
+
data.tar.gz: f279bc9d3e83b175e0a375efd23f8d97db7538d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa735b7f0551635eed1627275afcb2b36b58dffc0236912baa06b257079b24627a1dca74d20cee75df16b24543069395600b6a9b059da3c57e3116907047e952
|
7
|
+
data.tar.gz: f3df3bfd2cb0ef71fb9c9885a00bb8f0580015a03663b1f0a39a1c89642841bfd7b99cf3c8bac371923c44cabe2496dec4b0a6ed114ef38ed0ee5b3a2d712bd2
|
data/README.md
CHANGED
@@ -6,33 +6,36 @@ Think wearing a giant robot exo-skeleton with lasers and missile launchers while
|
|
6
6
|
|
7
7
|
### It has the good stuff
|
8
8
|
Features include:
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
9
|
+
* RESTful routing
|
10
|
+
* Sensible templates: layouts and views separate
|
11
|
+
* RoR-esque code generation
|
12
|
+
* PHP-ActiveRecord for ORM: No SQL needed!
|
13
|
+
* Installs dependencies quickly and easily with Composer
|
14
|
+
* Built in Ruby: Who doesn't love Ruby?
|
15
15
|
|
16
16
|
### It takes care of the bad stuff
|
17
17
|
Don't worry about:
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
18
|
+
* annoying PHP syntax errors
|
19
|
+
* copy-pasting or otherwise repeating code
|
20
|
+
* SQL, SQL injection, escaping strings, etc
|
21
|
+
* URLs that look ugly
|
22
|
+
* PHP being stupid in general
|
23
23
|
|
24
24
|
### How do I do it?
|
25
25
|
To start using Ptero, make sure your PHP command-line tool is up-to-date, then run the following:
|
26
|
+
|
26
27
|
```bash
|
27
28
|
$ gem install ptero
|
28
29
|
```
|
29
30
|
|
30
31
|
Now make an application:
|
32
|
+
|
31
33
|
```bash
|
32
34
|
$ ptero new Blog
|
33
35
|
```
|
34
36
|
|
35
37
|
There! Your web application is seeded and ready. Now you can start generating files.
|
38
|
+
|
36
39
|
```bash
|
37
40
|
$ cd Blog
|
38
41
|
$ ptero generate page hippo
|
@@ -45,7 +48,8 @@ Now run an apache server with root directory Blog/www, and navigate to http://lo
|
|
45
48
|
### Onward!
|
46
49
|
Now for the best part. Let's take a look at the generated code.
|
47
50
|
|
48
|
-
Here's the default controller, Blog/php/controllers/HippoController.php
|
51
|
+
Here's the default controller, Blog/php/controllers/HippoController.php:
|
52
|
+
|
49
53
|
```php
|
50
54
|
/*
|
51
55
|
*
|
@@ -99,6 +103,7 @@ Notice that the template has only a few lines of code, and that it extends a lay
|
|
99
103
|
In this way, global layout changes can be made to the global application template, and individual changes made to individual pages.
|
100
104
|
|
101
105
|
For example, let's try doing some arbitrary server-side work and sending it to the client:
|
106
|
+
|
102
107
|
```php
|
103
108
|
// HippoController.php
|
104
109
|
|
@@ -119,6 +124,7 @@ class HippoController extends ApplicationController {
|
|
119
124
|
}
|
120
125
|
```
|
121
126
|
the template:
|
127
|
+
|
122
128
|
```twig
|
123
129
|
{% extends 'application.html.twig' %}
|
124
130
|
|
@@ -138,7 +144,8 @@ the template:
|
|
138
144
|
Now our code will print the $sum variable passed to it by the server.
|
139
145
|
|
140
146
|
### Routing
|
141
|
-
We already did some routing with the `$ptero route` command, but routes are also stored in a file and editable by hand. Let's open Blog/php/routes.php
|
147
|
+
We already did some routing with the `$ptero route` command, but routes are also stored in a file and editable by hand. Let's open Blog/php/routes.php:
|
148
|
+
|
142
149
|
```php
|
143
150
|
// Application route maps
|
144
151
|
$application->route(array(
|
@@ -150,16 +157,19 @@ $application->route(array(
|
|
150
157
|
Look! The route we made is there! It maps the string '/hippo' to the controller class Blog\Controllers\HippoController.
|
151
158
|
|
152
159
|
You can also print all current routes by running
|
160
|
+
|
153
161
|
```bash
|
154
162
|
$ ptero routes
|
155
163
|
```
|
156
164
|
|
157
165
|
We can try using RESTful parameters in our application and passing them to controllers. Try this:
|
166
|
+
|
158
167
|
```bash
|
159
168
|
$ ptero generate page rhino
|
160
169
|
$ ptero route /rhino/:number Rhino
|
161
170
|
```
|
162
171
|
Now edit php/controllers/RhinoController.php:
|
172
|
+
|
163
173
|
```php
|
164
174
|
namespace Blog\Controllers;
|
165
175
|
|
@@ -178,6 +188,7 @@ class RhinoController extends ApplicationController {
|
|
178
188
|
}
|
179
189
|
```
|
180
190
|
and make the template print our result:
|
191
|
+
|
181
192
|
```twig
|
182
193
|
{% block content %}
|
183
194
|
<!-- HTML content code produced by view: rhino -->
|
@@ -204,6 +215,7 @@ You'll have to bring your own SQL server. Sorry. Try [MAMP](http://www.mamp.info
|
|
204
215
|
Ptero uses PHP-ActiveRecord Databases, which are as easy as pie to use with a few minutes' practice. [Take a look.](http://www.phpactiverecord.org/projects/main/wiki/Quick_Start)
|
205
216
|
|
206
217
|
The first step of using Ptero databases is to configure your application. Open config/config.php:
|
218
|
+
|
207
219
|
```php
|
208
220
|
<?php
|
209
221
|
/*
|
@@ -236,12 +248,14 @@ return array(
|
|
236
248
|
Change the values 'database-name', 'username', 'password', and 'server' to the configuration of your database so that PHP-ActiveRecord knows where to look.
|
237
249
|
|
238
250
|
Now let's generate another page. We'll assume that we have a table called Elephants in our database that has a primary-key int "id", a string "name", and another int "age."
|
251
|
+
|
239
252
|
```bash
|
240
253
|
$ ptero generate page elephant
|
241
254
|
$ ptero generate model elephant
|
242
255
|
$ ptero route /elephants/:number Elephant
|
243
256
|
```
|
244
257
|
In php/controllers/ElephantController.php:
|
258
|
+
|
245
259
|
```php
|
246
260
|
<?php
|
247
261
|
|
@@ -279,6 +293,7 @@ class ElephantController extends ApplicationController {
|
|
279
293
|
?>
|
280
294
|
```
|
281
295
|
In views/elephant.twig:
|
296
|
+
|
282
297
|
```twig
|
283
298
|
{% extends 'application.html.twig' %}
|
284
299
|
|
@@ -299,6 +314,7 @@ In views/elephant.twig:
|
|
299
314
|
With this code in place, a request to http://localhost/elephants/n will output the information of elephant with id=n.
|
300
315
|
|
301
316
|
In this same way, you can create new Elephants and save them to the database by running something akin to:
|
317
|
+
|
302
318
|
```php
|
303
319
|
$dumbo = new \Blog\Models\Elephant();
|
304
320
|
$dumbo->name = 'dumbo';
|
@@ -315,6 +331,7 @@ This "destroy" command will delete or undo a create operation.
|
|
315
331
|
USE WITH CARE ON UNCOMMITTED CHANGES.
|
316
332
|
|
317
333
|
Here are some common inverse commands:
|
334
|
+
|
318
335
|
```bash
|
319
336
|
$ ptero new Slideshow # Create the Slideshow application
|
320
337
|
$ cd Slideshow
|
data/lib/ptero/version.rb
CHANGED
data/ptero.gemspec
CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ["LuminousRubyist"]
|
10
10
|
spec.email = ["luminousrubyist@zoho.com"]
|
11
11
|
spec.summary = "Command-line interface for Dinosaur projects."
|
12
|
-
spec.description = "
|
12
|
+
spec.description = "Ruby on Rails-style MVC framework for PHP. Builds fast and clean projects in seconds with pure-PHP controllers, templates, and models. RESTful routes, modular templates, databases without a drop of SQL. You won't be disappointed. Download this gem, then run `$ ptero new <appname>` and be on your merry way."
|
13
13
|
spec.homepage = "http://luminousrubyist.github.io/ptero/"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ptero
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- LuminousRubyist
|
@@ -108,8 +108,10 @@ dependencies:
|
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: 5.4.3
|
111
|
-
description:
|
112
|
-
|
111
|
+
description: Ruby on Rails-style MVC framework for PHP. Builds fast and clean projects
|
112
|
+
in seconds with pure-PHP controllers, templates, and models. RESTful routes, modular
|
113
|
+
templates, databases without a drop of SQL. You won't be disappointed. Download
|
114
|
+
this gem, then run `$ ptero new <appname>` and be on your merry way.
|
113
115
|
email:
|
114
116
|
- luminousrubyist@zoho.com
|
115
117
|
executables:
|