Browse Source

Merge pull request #219 from karllhughes/master

Composer support
Maurits van der Schee 8 years ago
parent
commit
dded42a3c8
3 changed files with 73 additions and 0 deletions
  1. 4
    0
      .gitignore
  2. 35
    0
      README.md
  3. 34
    0
      composer.json

+ 4
- 0
.gitignore View File

@@ -3,3 +3,7 @@
3 3
 .settings/
4 4
 phpunit.phar
5 5
 tests/config.php
6
+.idea/
7
+vendor
8
+composer.lock
9
+.DS_Store

+ 35
- 0
README.md View File

@@ -21,6 +21,8 @@ Related projects:
21 21
 
22 22
 This is a single file application! Upload "api.php" somewhere and enjoy!
23 23
 
24
+Alternatively, you can use [Composer](https://getcomposer.org/). See the _Composer Installation_ section below.
25
+
24 26
 ## Limitations
25 27
 
26 28
   - Primary keys should either be auto-increment (from 1 to 2^53) or UUID
@@ -1028,6 +1030,39 @@ string(6) "/posts"
1028 1030
 
1029 1031
 If it does not, something is wrong on your hosting environment.
1030 1032
 
1033
+## Composer Installation
1034
+
1035
+- Include the library in your composer.json file:
1036
+
1037
+```json
1038
+{
1039
+    "require": {
1040
+        "mevdschee/php-crud-api": "dev-master"
1041
+    }
1042
+}
1043
+```
1044
+
1045
+- Run `composer install`
1046
+- Use the library in your own code:
1047
+
1048
+```php
1049
+<?php
1050
+
1051
+include './vendor/autoload.php';
1052
+
1053
+// DB Connection
1054
+$api = new PHP_CRUD_API(array(
1055
+ 	'dbengine'=>'MySQL',
1056
+ 	'hostname'=>'localhost',
1057
+ 	'username'=>'',
1058
+ 	'password'=>'',
1059
+	'database'=>'',
1060
+	'charset'=>'utf8'
1061
+));
1062
+$api->executeCommand();
1063
+
1064
+```
1065
+
1031 1066
 ## License
1032 1067
 
1033 1068
 MIT

+ 34
- 0
composer.json View File

@@ -0,0 +1,34 @@
1
+{
2
+  "name": "mevdschee/php-crud-api",
3
+  "type": "library",
4
+  "description": "Single file PHP script that adds a REST API to a SQL database.",
5
+  "keywords": [
6
+    "api-server",
7
+    "restful",
8
+    "mysql",
9
+    "geospatial",
10
+    "sql-server",
11
+    "postgresql",
12
+    "php-api",
13
+    "postgis",
14
+    "crud",
15
+    "rest-api",
16
+    "openapi",
17
+    "swagger"
18
+  ],
19
+  "homepage": "https://github.com/mevdschee/php-crud-api",
20
+  "license": "MIT",
21
+  "authors": [
22
+    {
23
+      "name": "Maurits van der Schee",
24
+      "email": "maurits@vdschee.nl",
25
+      "homepage": "https://github.com/mevdschee"
26
+    }
27
+  ],
28
+  "require": {
29
+    "php": ">=5.6.0"
30
+  },
31
+  "autoload": {
32
+    "files": ["api.php"]
33
+  }
34
+}

Loading…
Cancel
Save