项目作者: maciejkosiarski

项目描述 :
symfony app with micro kernel
高级语言: PHP
项目地址: git://github.com/maciejkosiarski/symfony-rest-api.git
创建时间: 2017-07-07T16:29:03Z
项目社区:https://github.com/maciejkosiarski/symfony-rest-api

开源协议:

下载


symfony-rest-api

Symfony one file simple rest app with micro kernel.

How to run it

cd xampp/htdocs for windows

git clone https://github.com/maciejkosiarski/symfony-rest-api.git

cd symfony-rest-api

composer install

Create new database and import table from schema.sql

Configure doctrine in configureContainer method:

  1. $c->loadFromExtension('doctrine', [
  2. 'dbal' => [
  3. 'driver' => 'pdo_mysql',
  4. 'host' => '127.0.0.1',
  5. 'port' => null,
  6. 'dbname' => 'your_dbname',
  7. 'user' => 'your_user',
  8. 'password' => 'your_pass',
  9. 'charset' => 'UTF8'
  10. ]
  11. ]);

Your api is now available at http://localhost/symfony-rest-api/index.php/api/article

The api will respond to

GET -> api/article

GET -> api/article/{id}

POST -> api/article

PUT -> api/article/{id}

DELETE -> api/article/{id}

Authentication

user: admin

pass: secretpass

Configure security in configureContainer method:

  1. $c->loadFromExtension('security', [
  2. 'providers' => [
  3. 'in_memory' => [
  4. 'memory' => [
  5. 'users' => [
  6. 'admin' => [
  7. 'password' => 'secretpass',
  8. 'roles' => 'ROLE_ADMIN'
  9. ]
  10. ]
  11. ],
  12. ],
  13. ],
  14. ...