forked from Luracast/Restler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
688 lines (581 loc) · 29.7 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
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
<!DOCTYPE html>
<html>
<head>
<title>Luracast Restler Index</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="examples/resources/highlight.css">
<link rel="stylesheet" type="text/css" href="examples/resources/style.css"/>
<script src="examples/resources/highlight.pack.js"></script>
<script type="text/javascript" src="examples/resources/jquery-1.7.2.min.js"></script>
<script type="text/javascript">
hljs.initHighlightingOnLoad();
</script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-23777019-2']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
<body>
<nav class="floating-menu">
<ul>
<li><a title="Restler Home" target="_blank" href="http://luracast.com/products/restler/"><img src="examples/resources/home.png" width="16" height="16"/> Home</a></li>
<li><a class="active" title="Getting Started with Restler" href="index.html#luracast-restler"><img src="examples/resources/quickstart.png" width="16" height="16"/> Start</a></li>
<li><a href="examples/index.html"><img src="examples/resources/examples.png" width="16" height="16"/> Examples</a></li>
<li><a title="Share your knowledge by answering user questions in Stack Overflow." target="_blank" href="http://bit.ly/Restler-QA"><img src="examples/resources/stackoverflow.png" width="16" height="16"/> Support</a></li>
<li><a title="Contribute and Fork Restler on GitHub" target="_blank" href="http://bit.ly/LuracastRestler"><img src="examples/resources/github.png" width="16" height="16"/> Source</a></li>
<li><a title="Get updated on Twitter" target="_blank" href="http://twitter.com/Luracast"><img src="examples/resources/twitter.png" width="16" height="16"/> Update</a></li>
<li><a title="Keep in touch on Facebook" target="_blank" href="https://www.facebook.com/Luracast"><img src="examples/resources/facebook.png" width="16" height="16"/> Connect</a></li>
</ul>
</nav>
<nav id="left">
<img src="examples/resources/Restler3.gif" width="126"
height="126" title="Luracast Restler " />
<h3>
<a href="index.html#luracast-restler">Quick Start</a>
</h3>
<ul>
<li><a href="index.html#features" title="Feature List">Features</a></li>
<li><a href="index.html#git-repository-and-the-branches" title="Git Repository and the Branches">Branches</a></li>
<li><a href="index.html#installation" title="Install">Installation</a></li>
<li><a href="index.html#quick-start-guide" title="Quick Start">Getting Started</a></li>
<li><a href="index.html#change-log" title="What has changed?">Change Log</a></li>
<li><a href="annotations.html#supported-annotations" title="Supported Annotations">Annotations</a>
<ul><li><a href="annotations.html#url" title="Annotations - @url">@url</a></li></ul>
<ul><li><a href="annotations.html#access" title="Annotations - @access">@access</a></li></ul>
<ul><li><a href="annotations.html#smart-auto-routing" title="Annotations - @smart-auto-routing">@smart-auto...</a></li></ul>
<ul><li><a href="annotations.html#class" title="Annotations - @class">@class</a></li></ul>
<ul><li><a href="annotations.html#cache" title="Annotations - @cache">@cache</a></li></ul>
<ul><li><a href="annotations.html#expires" title="Annotations - @expires">@expires</a></li></ul>
<ul><li><a href="annotations.html#throttle" title="Annotations - @throttle">@throttle</a></li></ul>
<ul><li><a href="annotations.html#status" title="Annotations - @status">@status</a></li></ul>
<ul><li><a href="annotations.html#header" title="Annotations - @header">@header</a></li></ul>
<ul><li><a href="annotations.html#param" title="Annotations - @param">@param</a></li></ul>
<ul><li><a href="annotations.html#throws" title="Annotations - @throws">@throws</a></li></ul>
<ul><li><a href="annotations.html#return" title="Annotations - @return">@return</a></li></ul>
<ul><li><a href="annotations.html#var" title="Annotations - @var">@var</a></li></ul>
<ul><li><a href="annotations.html#format" title="Annotations - @format">@format</a></li></ul>
<ul><li><a href="annotations.html#view" title="Annotations - @view">@view</a></li></ul>
<ul><li><a href="annotations.html#errorview" title="Annotations - @errorView">@errorView</a></li></ul>
</li>
<li><a href="forms.html#forms" title="Forms">Forms</a>
<ul><li><a href="forms.html#label" title="Forms - @label">@label</a></li></ul>
<ul><li><a href="forms.html#field" title="Forms - @field">@field</a></li></ul>
<ul><li><a href="forms.html#message" title="Forms - @message">@message</a></li></ul>
<ul><li><a href="forms.html#form" title="Forms - @form">@form</a></li></ul>
<ul><li><a href="forms.html#input" title="Forms - @input">@input</a></li></ul>
<ul><li><a href="forms.html#textarea" title="Forms - @textarea">@textarea</a></li></ul>
<ul><li><a href="forms.html#radio" title="Forms - @radio">@radio</a></li></ul>
<ul><li><a href="forms.html#select" title="Forms - @select">@select</a></li></ul>
<ul><li><a href="forms.html#submit" title="Forms - @submit">@submit</a></li></ul>
<ul><li><a href="forms.html#fieldset" title="Forms - @fieldset">@fieldset</a></li></ul>
</li>
<li><a href="param.html#param-and--var" title="@param and @var">Param</a>
<ul><li><a href="param.html#from" title="Param - @from">@from</a></li></ul>
<ul><li><a href="param.html#type" title="Param - @type">@type</a></li></ul>
<ul><li><a href="param.html#choice" title="Param - @choice">@choice</a></li></ul>
<ul><li><a href="param.html#min----max" title="Param - @min & @max">@min & @max</a></li></ul>
<ul><li><a href="param.html#fix" title="Param - @fix">@fix</a></li></ul>
<ul><li><a href="param.html#pattern" title="Param - @pattern">@pattern</a></li></ul>
<ul><li><a href="param.html#message" title="Param - @message">@message</a></li></ul>
<ul><li><a href="param.html#example" title="Param - @example">@example</a></li></ul>
</li>
</ul>
</nav>
<article>
<p><a id="luracast-restler" class="anchor"></a></p>
<h1>
<img src="examples/resources/Restler.png" alt="Restler"> Luracast Restler</h1>
<p><a href="https://packagist.org/packages/luracast/restler" target="_blank"><img src="https://poser.pugx.org/luracast/restler/v/stable.png" alt="Latest Stable Version"></a> <a href="https://packagist.org/packages/luracast/restler" target="_blank"><img src="https://poser.pugx.org/luracast/restler/downloads.png" alt="Total Downloads"></a> <a href="https://packagist.org/packages/luracast/restler" target="_blank"><img src="https://poser.pugx.org/luracast/restler/v/unstable.png" alt="Latest Unstable Version"></a> <a href="https://packagist.org/packages/luracast/restler" target="_blank"><img src="https://poser.pugx.org/luracast/restler/license.png" alt="License"></a></p>
<p><a id="version-3-0-release-candidate-5" class="anchor"></a></p>
<h3>Version 3.0 Release Candidate 5</h3>
<p>Restler is a simple and effective multi-format Web API Server written in PHP.</p>
<p>Just deal with your business logic in php, restler will take care of the REST!</p>
<blockquote>
<p>if you do not have PHP >= 5.3.2 on your server and wont be able to upgrade you may
use <a href="https://github.com/Luracast/Restler/tree/v2" target="_blank">Restler 2</a> instead</p>
</blockquote>
<p><a id="restler-3----better-apis-by-design" class="anchor"></a></p>
<h3>Restler 3 - <em>Better APIs by Design</em>
</h3>
<ul>
<li><a href="http://luracast.com/products/restler/" target="_blank">Developer Home</a></li>
<li><a href="http://bit.ly/Restler3LiveExamples" target="_blank">Live Examples</a></li>
<li>Updates on <a href="https://www.facebook.com/Luracast" target="_blank">Facebook</a> and <a href="http://twitter.com/Luracast" target="_blank">Twitter</a>
</li>
<li><a href="#features" target="_blank">Features</a></li>
<li><a href="#installation" target="_blank">Installation</a></li>
<li><a href="#quick-start-guide" target="_blank">Quick Start Guide</a></li>
<li><a href="#change-log" target="_blank">Change Log</a></li>
</ul>
<p><a id="features" class="anchor"></a></p>
<h2>Features</h2>
<ul>
<li>No Learning Curve</li>
<li>Light weight</li>
<li>Flexible</li>
<li>Highly Customizable</li>
<li>Many Examples that can be tried on your localhost to get started</li>
<li>Supports HTTP request methods HEAD, GET, POST, PUT, DELETE, OPTIONS and PATCH
via header or request parameter (method)</li>
<li>Supports both RESTful and Pragmatic REST API Design</li>
<li>Clients can use X-HTTP-Method-Override header, supports Cross Origin Resource
Sharing and JSONP</li>
<li>Two way format(media type) conversion both send and receive
<ul>
<li>Pluggable content Formatter framework and api</li>
<li>Comes with JSON, XML, Yaml, Amf, and Plist(both XML and Binary) format
support</li>
</ul>
</li>
<li>Pluggable Authentication schemes
<ul>
<li>OAuth 2 Server</li>
</ul>
</li>
<li>Pluggable Filters to effectively manage API usage
<ul>
<li>API Rate Limiting Filter</li>
</ul>
</li>
<li>Routing
<ul>
<li>Manual Routing (Annotation)
<ul>
<li>Using <code>@url GET my/custom/url/{param}</code> PHPDoc comments</li>
</ul>
</li>
<li>Auto Routing (Reflection)
<ul>
<li>URL to Method mapping</li>
<li>URL part to Method parameter mapping</li>
<li>Query parameters to Method parameter mapping</li>
<li>Request body to Method parameter mapping</li>
<li>
<code>[planned]</code> Header to Method parameter mapping</li>
</ul>
</li>
</ul>
</li>
<li>Cache built-in
<ul>
<li>Client Side Caching support</li>
<li>Proxy Caching support</li>
<li>Server Side Caching
<ul>
<li>
<code>[planned]</code> ETag, If-None-Match support</li>
<li>
<code>[planned]</code> Last-Modified, If-Modified-Since support</li>
</ul>
</li>
</ul>
</li>
<li>API Features
<ul>
<li>Always supports URLEncoded format for simplified input (POST vars)</li>
<li>Automatic parameter validation and type conversion</li>
<li>API versioning support by URL and/or vendor specific MIME</li>
<li>API documentation and discovery using <a href="https://github.com/Luracast/Restler-API-Explorer" target="_blank">Restler API Explorer</a>
</li>
<li>Throttling and Performance tuning</li>
</ul>
</li>
<li>Management
<ul>
<li>
<code>[planned]</code> Unit Testing using <a href="https://github.com/sebastianbergmann/phpunit/" target="_blank">PHPUnit</a>
</li>
<li>Behavior Driven API testing using <a href="http://behat.org/" target="_blank">Behat</a> and <a href="https://github.com/guzzle/guzzle" target="_blank">Guzzle</a>
</li>
<li>Command line Project Management using <a href="https://github.com/Respect/Foundation" target="_blank">Respect/Foundation</a>
</li>
<li>Dependency Management using <a href="http://getcomposer.org/" target="_blank">Composer</a>
</li>
<li>Source code distributed under LGPL</li>
</ul>
</li>
</ul>
<p><a id="git-repository-and-the-branches" class="anchor"></a></p>
<h2>Git Repository and the Branches</h2>
<ol>
<li><p>Most stable and recent version is maintained at the <code>master</code> branch, previous
versions are kept in the branches such as <code>v1</code> and <code>v2</code></p></li>
<li><p>Version branch with the current version such as <code>v3</code> is used for building up
the next release. It's documentation may not be updated frequently and thus
reserved for the daring ones.</p></li>
<li><p>Feature branches such as <code>../features/html</code> and <code>../features/router</code> are purely
for experimentation purpose to try out a feature</p></li>
</ol>
<p><a id="installation" class="anchor"></a></p>
<h2>Installation</h2>
<p>Make sure PHP 5.3.2 or above (at least 5.3.4 recommended to avoid potential bugs)
is available on your server</p>
<p><a id="1--install-composer" class="anchor"></a></p>
<h3>1. Install Composer</h3>
<p>Restler uses <a href="http://getcomposer.org/" target="_blank">Composer</a> to manage its dependencies.
First, download a copy of <code>composer.phar</code>. It can be kept in your project folder
or ideally in <code>usr/local/bin</code> to use it globally for all your projects. If you
are on Windows, you can use the composer
<a href="https://getcomposer.org/Composer-Setup.exe" target="_blank">windows installer</a> instead.</p>
<p><a id="2--install-restler" class="anchor"></a></p>
<h3>2. Install Restler</h3>
<p><a id="option-1--using-composer-create-project" class="anchor"></a></p>
<h4>Option 1. Using composer create-project</h4>
<p>You may install Restler by running the create project command in your terminal.
Replace {projectName} with your actual project name. It will create a folder
with that name and install Restler.</p>
<pre><code class="console">php composer.phar create-project luracast/restler {projectName}
</code></pre>
<blockquote>
<p><strong>Note:-</strong></p>
<ol>
<li><p>If you do not want the additional formats and BDD tools you can include
<code>--no-dev</code> to enforce exclusion of dev packages.</p></li>
<li><p>If you want to try the bleading edge v3 branch or any of the feature
branches include <code>3.x-dev</code> or <code>dev-../features/html</code> in the above command</p></li>
</ol>
</blockquote>
<p><a id="option-2--downloading-from-github" class="anchor"></a></p>
<h4>Option 2. Downloading from github</h4>
<p>Once Composer is installed, download the <a href="" target="_blank">latest version</a> of the Restler
framework and extract its contents into a directory on your server. Next, in the
root of your Restler project, run the <code>php composer.phar install</code>
(or <code>composer install</code>) command to install all of the framework's dependencies.
This process requires Git to be installed on the server to successfully complete
the installation.</p>
<p>If you want to update the Restler framework, you may issue the
<code>php composer.phar update</code> command.</p>
<blockquote>
<p><strong>Note:-</strong> If are not allowed to install composer and git on your server, you
can install and run them on your development machine. The resulting files and
folders can be uploaded and used on the server.</p>
</blockquote>
<p><a id="3--configure" class="anchor"></a></p>
<h3>3. Configure</h3>
<p>Ideally public folder should be mapped as your web root, It is optional, but
recommended to avoid exposing unneeded files and folders.</p>
<p><a id="4--try-it-out" class="anchor"></a></p>
<h3>4. Try it out</h3>
<p>Try the live examples in your localhost</p>
<p><a id="5--run-some-test" class="anchor"></a></p>
<h3>5. Run some test</h3>
<p>Update the base_url specified in <code>behat.yml</code> and then try the following command</p>
<pre><code class="console"><br>bin/behat
</code></pre>
<p>This will test the examples against the behaviors expected, for example</p>
<pre><code class="gherkin"><br>Feature: Testing CRUD Example
Scenario: Creating new Author with JSON
Given that I want to make a new "Author"
And his "name" is "Chris"
And his "email" is "[email protected]"
And the request is sent as JSON
When I request "/examples/_007_crud/authors"
Then the response status code should be 200
And the response should be JSON
And the response has a "id" property
</code></pre>
<p>All set, Happy Restling! :)</p>
<p><a id="quick-start-guide" class="anchor"></a></p>
<h2>Quick Start Guide</h2>
<p>Once you have got restler installed with the above steps, you can quickly create
your application by following these steps</p>
<p><a id="1--write-api" class="anchor"></a></p>
<h3>1. Write API</h3>
<p>Create your <strong>API classes</strong> with all needed public and protected methods</p>
<p><a id="2--open-the-gateway" class="anchor"></a></p>
<h3>2. Open the Gateway</h3>
<p>Create the <strong>gateway (index.php)</strong> as follows</p>
<pre><code class="php"><?php
require_once '../../../vendor/restler.php';
use Luracast\Restler\Restler;
$r = new Restler();
$r->addAPIClass('YourApiClassNameHere'); // repeat for more
$r->handle(); //serve the response
</code></pre>
<p><a id="3--prettify-urls" class="anchor"></a></p>
<h3>3. Prettify URLs</h3>
<p><strong>Enable URL Rewriting</strong></p>
<p>Make sure all the requests are routed to index.php by enabling URL Rewriting for
your website</p>
<p>For example:-</p>
<p>If you are on Apache, you can use an .htaccess file such as</p>
<pre><code class="apache">DirectoryIndex index.php
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^$ index.php [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
<IfModule mod_php5.c>
php_flag display_errors On
</IfModule>
</code></pre>
<blockquote>
<p><strong>Note:-</strong> This requires <code>AllowOverride</code> to be set to <code>All</code> instead of <code>None</code>
in the <code>httpd.conf</code> file, and might require some tweaking on some server
configurations. Refer to <a href="http://httpd.apache.org/docs/current/mod/mod_rewrite.html" target="_blank">mod_rewrite</a>
documentation for more info.</p>
</blockquote>
<p>If you are on Nginx, you have to make sure you set the <code>server_name</code> and pass the
PHP scripts to fast cgi (PHP-FPM) listening on 127.0.0.1:9000</p>
<pre><code>server {
listen 80;
server_name api.luracast.com; //change it to match your server name
//... other stuff
location ~ \.php$ {
root /var/www/html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/html/$fastcgi_script_name;
include fastcgi_params;
}
//... other stuff
}
</code></pre>
<blockquote>
<p><strong>Note:-</strong> This requires PHP, PHP-FPM to be properly installed and configured.
Refer to <a href="http://wiki.nginx.org/PHPFcgiExample" target="_blank">PHP FastCGI</a> example for more
info.</p>
</blockquote>
<p><a id="4--customise" class="anchor"></a></p>
<h3>4. Customise</h3>
<p><strong>Fine tune to suit your needs</strong></p>
<pre><code class="php"><?php
require_once '../../../vendor/restler.php';
use Luracast\Restler\Restler;
use Luracast\Restler\Defaults;
//set the defaults to match your requirements
Defaults::$throttle = 20; //time in milliseconds for bandwidth throttling
//setup restler
$r = new Restler();
$r->addAPIClass('YourApiClassNameHere'); // repeat for more
$r->addAPIClass('Resources'); //from restler framework for API Explorer
$r->addFilterClass('RateLimit'); //Add Filters as needed
$r->handle(); //serve the response
</code></pre>
<p>If you have successfully completed Installation Step 2, you should have
<a href="https://github.com/Luracast/Restler-API-Explorer" target="_blank">Restler API Explorer</a> installed
in <code>vendor/Luracast/explorer</code> folder. Create a symbolic link of
<code>vendor/Luracast/explorer/dist</code> or copy the folder and name it as <code>explorer</code></p>
<p>Place the explorer in the same folder as the <code>index.php</code></p>
<p>Explore the api and try it out by openings <code>explorer/index.html</code> from the web
root on your browser</p>
<p>Happy Exploring! :)</p>
<blockquote>
<p><strong>Note:-</strong> Using eAccelerator can make restler to fail as it removes the
comments. More info can be found <a href="http://wildlyinaccurate.com/eaccelerator-and-doctrine-2" target="_blank">here</a></p>
</blockquote>
<p><a id="5--annotate" class="anchor"></a></p>
<h3>5. Annotate</h3>
<p>Restler supports annotations in the form of PHPDoc comments for API fine tuning</p>
<p>They are documented in detail under <a href="annotations.html" target="_blank">Annotations</a></p>
<p><a id="6--authorize" class="anchor"></a></p>
<h3>6. Authorize</h3>
<p>In order to protect your api, authenticate and allow valid users</p>
<pre><code class="php"><?php
require_once '../../../vendor/restler.php';
use Luracast\Restler\Restler;
$r = new Restler();
$r->addAPIClass('YourApiClassNameHere'); // repeat for more
$r->addAuthenticationClass('CustomAuth'); //Add Authentication classes as needed
$r->handle(); //serve the response
</code></pre>
<p><a id="7--start-production" class="anchor"></a></p>
<h3>7. Start Production</h3>
<p>By default Restler runs in debug mode more fine tuned for API developer, by
showing detailed error messages and prettifying the api result to human readbale
form</p>
<p>By turning on production mode you will gain some performance boost as it will
cache the routes (comment parsing happens only once instead of every api call),
few other files and avoid giving out debug information</p>
<pre><code class="php"><?php
require_once '../../../vendor/restler.php';
use Luracast\Restler\Restler;
//setup restler
$r = new Restler(true); //turn on production mode by passing true.
//If you are using file based cache (the default) make sure cache folder is
//writable. when you make changes to your code make sure you delete the
// routes.php inside the cache folder
//...
</code></pre>
<p><a id="change-log" class="anchor"></a></p>
<h2>Change Log</h2>
<p><a id="restler-3-0-rc5" class="anchor"></a></p>
<h3>Restler 3.0 RC5</h3>
<ul>
<li>Scope (an dependency injection container) is added. It's register method allows adding api classes that has some dependencies.</li>
<li>Improves HtmlFormat to support blade templates and makes it easily extendable to add your own templates.</li>
<li>HtmlFormat::$format has been renamed as HtmlFormat::$template for better clarrity</li>
<li>HtmlFormat now supports auto templating to load relevant template for an API method based on the mapped url.</li>
<li>Tag, a utility class for generating html tags in object oriented way.</li>
<li>Emmet class that extends a subset of emmet to create a a template engine.</li>
<li>Forms class to auto generate forms for any API method prebuilt in HTML5, Twitter Bootstrap 3, Zurb Foundation formats.</li>
<li>Validator improved to allow suppressing validation errors from throwing exceptions immediatly, so that API call can reach the API method</li>
<li>Validator improved to be form validation friendly.</li>
<li>Nav class creating html navigation interface.</li>
<li>OAuth examles updgrated to use version 1.0 of OAuth2 library.</li>
<li>Many bug fixes and improvements.</li>
</ul>
<p><a id="restler-3-0-rc4" class="anchor"></a></p>
<h3>Restler 3.0 RC4</h3>
<ul>
<li>
<code>$reques_data</code> in api method parameters and <code>getRequestData()</code> on restler
instance now excludes <code>$_GET</code> parameters.</li>
<li>Returning null from api method now excludes the response body. This behaviour
can be changed by setting <code>Defaults::$emptyBodyForNullResponse</code> to false.</li>
<li>Added many api examples under tests folder for testing feature by feature
using BDD</li>
<li>Support for custom class parameters and array of custom class parameters</li>
<li>Ability to pass the parameter directly as the body of the request when it is
the only parameter</li>
<li>Fixes to composer.json and publish stable release as composer package on
packagist.</li>
<li>New Routes class with improved routing, including wild card routes and smart
routing based on paramter type.</li>
<li>Possibility to use any autoloader including composer's autoloader for maximum
interoperability</li>
<li>Moved to using the <a href="https://packagist.org/packages/rodneyrehm/plist" target="_blank">rodneyrehm/plist</a>
package for CFPropertyList.</li>
<li>Removed required packages as they are not technically "required" per se,
Restler works out of the box.</li>
<li>Created supported packages as require-dev instead which will be installed via
<code>composer install --dev</code>
</li>
<li>Added suggested section for all the supported packages.</li>
<li>Added keywords to package descriptor</li>
<li>Added branch alias to indicate that v3 is the snapshot for v3.0.x-dev</li>
<li>Released Restler as package on packagist.</li>
</ul>
<p><a id="restler-3-0-rc3" class="anchor"></a></p>
<h3>Restler 3.0 RC3</h3>
<ul>
<li>Added Defaults::$cacheDirectory to set cache directory in one central place</li>
<li>Added JSONP support with JsFormat class by extending JsonFormat.</li>
<li>Fixes fatal error when the JSON sent in the request body is not an object or
array</li>
<li>Improves inline comment parsing by array conversion when delimiter is found
and tag is not @pattern</li>
<li>RateLimit class re-written to support all range of time units
second|minute|hour|day|week|month to have fine grained control</li>
<li>Resources class improved to include description for body parameters</li>
<li>Fixes Resources not to include namespace when the return type is array of
custom class</li>
<li>Fixed Resource not to include the API of another class when the current api
name is a begins with part of the other API</li>
<li>Added two more ways to exclude API's from explorer/documentation
<ul>
<li>
<code>Resources::$excludedHttpMethods</code> (array)</li>
<li>
<code>Resources::$excludedPaths</code> (array)</li>
</ul>
</li>
<li>Fixes unescaped unicode bug in PHP < 5.4</li>
<li>Fixes a bug with ValidationInfo parsing @choice inline comment</li>
<li>Added Charset support</li>
<li>Added Language (basic) support</li>
<li>Updated the BDD tests to include new features</li>
<li>Fixes a bug in Restler class which affects $_GET overriding <code>Defaults</code>
</li>
<li>Fixes a bug in XmlFormat parsing XML content to array</li>
<li>Added support for JSONP via jsFormat extension of JsonFormat</li>
<li>Fixes a bug in unicode un-escaping for JsonFormat in PHP < 5.4</li>
<li>Fixes the order so that responseFormat->setCharset is called before encoding
the response</li>
<li>Documentation improvements and minor bug fixes</li>
</ul>
<p><a id="restler-3-0-rc2" class="anchor"></a></p>
<h3>Restler 3.0 RC2</h3>
<ul>
<li>Filter classes can use authentication status and respond differently for
authenticated users by implementing iUseAuthentication interface</li>
<li>
<code>RateLimit</code> class added to rate limit the api usage</li>
<li>Fixed a bug with setCompatibilityMode</li>
<li>Resources updated to use only paths for resource identification instead of
class name
<ul>
<li>Enabled Access Control for Documentation</li>
</ul>
</li>
<li>Fixed CommentParser to ignore repeated white space so that it parses comments
correctly</li>
<li>Fixed comment parsing for @status and @expires tags</li>
<li>Added the following Examples
<ul>
<li>Documentation</li>
<li>Rate Limit</li>
<li>Access Control</li>
</ul>
</li>
<li>CRUD example updated to include PATCH support</li>
</ul>
<p><a id="restler-3-0" class="anchor"></a></p>
<h3>Restler 3.0</h3>
<p><strong>Restler 3.0</strong> is completely rewritten from Restler 2.0 with best practices in
mind for</p>
<ul>
<li>PHP Coding</li>
<li>RESTfulness and/or Pragmatic REST</li>
<li>API Design</li>
</ul>
<p><strong>Restler 3.0</strong></p>
<ul>
<li>uses namespaces, Late Static Bindings, and Closures and thus it is <strong>PHP 5.3+</strong>
only (if you need <strong>PHP 5.0+</strong> support use <a href="https://github.com/Luracast/Restler/tree/v2" target="_blank">Restler 2</a>)</li>
<li>provides backward compatibility for Restler 1 and 2.
Use <code>$r->setCompatibilityMode($version);</code>
</li>
<li>supports hybrid api which provides extended data to authenticated users
Use <code>@access hybrid</code> PHPDoc comment</li>
<li>uses smart auto routing by default where API method parameters that
have default values are no longer mapped to the URL, instead they are
mapped to query strings to reduce ambiguity in the url.</li>
<li>supports <code>suppress_response_codes</code> as query string, when set to true;
all http responses will be returned with HTTP OK with the errors in the
body to accommodate mobile and less privileged clients.</li>
<li>has improved <code>CommentParser</code> which adds support for embedded data in multiple
formats
<ul>
<li>inline doc comments <code>{@name value}</code>
</li>
<li>query string params ``` param1=value&param2=value2```</li>
<li>json ``` {"param1": value, "param2": value2}``` which can be placed
in multi-lines</li>
</ul>
</li>
<li>has <code>Defaults</code> class with static properties that can be changed to suit the
needs</li>
<li>iAuthenticate is now using <code>__isAllowed</code> method instead of <code>__isAuthenticated</code>
so that same
class can be used for Authentication or Filtering</li>
<li>iUseAuthentication interface added to help hybrid access api methods and
filters to find out about user authentication status</li>
<li>iFilter interface updated to provide charset support</li>
<li>...(more to follow)</li>
</ul>
<p><a id="restler-2-0" class="anchor"></a></p>
<h3>Restler 2.0</h3>
<p>Restler 2.0 is a major rewrite to use convention over configuration and it is
optimized for performance. Here are some of the major changes and improvements</p>
<ul>
<li>PHPDoc comments to map a method to URI are now optional.</li>
<li>All public methods that does not begin with an underscore are mapped
automatically to the method name (<code>gateway\classname\methodname\param1\...</code>)</li>
<li>If we do not specify the second parameter for
<code>$restler->addAPIClass</code> it will be mapped to the class name instead of mapping
it to the root</li>
<li>Restler 2 is written for PHP 5.3 and above but it make use of compat.php and
work on any version of PHP starting from PHP 5.0</li>
</ul>
</article>
</body>
</html>