Skip to content

Commit deb68e0

Browse files
authored
Merge pull request #530 from mevdschee/psr7
Implement PSR-7, PSR-15 and PSR-17
2 parents 9a37047 + b26cef0 commit deb68e0

File tree

144 files changed

+8333
-1521
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

144 files changed

+8333
-1521
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
composer.phar
2+
composer.lock
3+
.git

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2018 Maurits van der Schee
3+
Copyright (c) 2019 Maurits van der Schee
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

+20-34
Original file line numberDiff line numberDiff line change
@@ -71,18 +71,6 @@ These are all the configuration options and their default value between brackets
7171
- "cacheTime": Number of seconds the cache is valid (`10`)
7272
- "debug": Show errors in the "X-Debug-Info" header (`false`)
7373

74-
## Compilation
75-
76-
The code resides in the "`src`" directory. You can access it at the URL:
77-
78-
http://localhost:8080/src/records/posts/1
79-
80-
You can compile all files into a single "`api.php`" file using:
81-
82-
php build.php
83-
84-
NB: The script appends the classes in alphabetical order (directories first).
85-
8674
## Limitations
8775

8876
These limitation and constrains apply:
@@ -115,34 +103,32 @@ The following features are supported:
115103
- Spatial/GIS fields and filters supported with WKT
116104
- Generate API documentation using OpenAPI tools
117105
- Authentication via JWT token or username/password
106+
- Support for reading database structure in JSON
107+
- Support for modifying database structure using REST endpoint
108+
- Security enhancing middleware is included
109+
- Standard compliant: PSR-2, PSR-4, PSR-7, PSR-15 and PSR-17
110+
111+
## Compilation
112+
113+
You can compile all files into a single "`api.php`" file using:
118114

119-
### Extra Features
115+
php build.php
116+
117+
You can access the non-compiled code at the URL:
118+
119+
http://localhost:8080/src/records/posts/1
120120

121-
These features are new in v2 and were not included in v1:
121+
The non-compiled code resides in the "`src`" and "`vendor`" directories.
122122

123-
- Does not reflect on every request (better performance)
124-
- Complex filters (with both "and" & "or") are supported
125-
- Support for output of database structure in JSON
126-
- Support for boolean and binary data in all database engines
127-
- Support for relational data on read (not only on list operation)
128-
- Support for middleware to modify all operations (also list)
129-
- Error reporting in JSON with corresponding HTTP status
130-
- Support for basic authentication and via auth provider (JWT)
131-
- Support for basic firewall functionality
132-
- Prevent database scraping using list limits
123+
### Updating dependencies
133124

134-
### Dropped features
125+
You can update all dependencies of this project using the following command:
135126

136-
The following features of v1 were dropped in v2:
127+
php update.php
137128

138-
- ~~Streaming data, low memory footprint~~
139-
- ~~Supports file upload from web forms (multipart/form-data)~~
140-
- ~~Condensed JSON output: first row contains field names~~
141-
- ~~Relation "transforms" (of condensed JSON) for PHP and JavaScript~~
142-
- ~~Unstructured data support through JSON/JSONB~~
143-
- ~~SQLite support~~
129+
This script will install and run [Composer](https://getcomposer.org/) to update the required dependencies in the "`vendor`" directory.
144130

145-
NB: You can find v1 here: https://github.com/mevdschee/php-crud-api/tree/v1
131+
NB: The update script will also patch the dependencies in the vendor directory for PHP 7.0 compatibility.
146132

147133
## Middleware
148134

@@ -782,7 +768,7 @@ You may use the "customization" middleware to modify request and response and im
782768
$environment->start = microtime(true);
783769
},
784770
'customization.afterHandler' => function ($operation, $tableName, $response, $environment) {
785-
$response->addHeader('X-Time-Taken', microtime(true) - $environment->start);
771+
return $response->withHeader('X-Time-Taken', microtime(true) - $environment->start);
786772
},
787773

788774
The above example will add a header "X-Time-Taken" with the number of seconds the API call has taken.

0 commit comments

Comments
 (0)