Skip to content

Commit dded42a

Browse files
authored
Merge pull request #219 from karllhughes/master
Composer support
2 parents 2e320f3 + 532018b commit dded42a

File tree

3 files changed

+73
-0
lines changed

3 files changed

+73
-0
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,7 @@
33
.settings/
44
phpunit.phar
55
tests/config.php
6+
.idea/
7+
vendor
8+
composer.lock
9+
.DS_Store

README.md

+35
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ Related projects:
2121

2222
This is a single file application! Upload "api.php" somewhere and enjoy!
2323

24+
Alternatively, you can use [Composer](https://getcomposer.org/). See the _Composer Installation_ section below.
25+
2426
## Limitations
2527

2628
- Primary keys should either be auto-increment (from 1 to 2^53) or UUID
@@ -1028,6 +1030,39 @@ string(6) "/posts"
10281030

10291031
If it does not, something is wrong on your hosting environment.
10301032

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+
10311066
## License
10321067

10331068
MIT

composer.json

+34
Original file line numberDiff line numberDiff line change
@@ -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+
}

0 commit comments

Comments
 (0)