PHP API Tutorial Training Server: Implementation of a REST API for learning purposes

Recommend this page to a friend!
  Info   View files Example   View files View files (87)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2021-09-11 (Yesterday) RSS 2.0 feedNot yet rated by the usersTotal: 29 This week: 1All time: 10,285 This week: 182Up
Version License PHP version Categories
training-server 1.0.0MIT/X Consortium ...5HTTP, PHP 5, Libraries, Web services
Description Author

This package provides an implementation of a REST API for learning purposes.

It provides all the files to implement an API using REST HTTP requests, including user authentication using OAuth.

The package provides an API example implementation endpoints to demonstrate features like registered user access, setting cookies in the API responses, and retrieving file data as responses.

It also provides files to set up a Docker container to test the provided API.

Picture of Kamil
  Performance   Level  
Name: Kamil <contact>
Classes: 2 packages by
Country: Poland Poland

Details

Training server for RestControl

TrainingServer contains several REST endpoints e.q. with oAuth/basic authentication, which you can use for learning RestControl.

Installation

 make build
 make first-run

Start server

 make start

Usage

 # Run all tests
 make run-tests

Endpoints

-> Plain api(without any authorization)

(GET) http://IP_ADDR/plain/users

Sample response:

[
  [
      "id": 1,
      "name": "Sample name",
      "email": "sample@email.com",
      "password": "sample_long_password_string",
      "remember_token": null,
      "created_at": "2018-01-01 10:00:00",
      "updated_at": "2018-01-01 10:00:00",
  ],
  [
      "id": 2,
      "name": "Sample name",
      "email": "another@email.com",
      "password": "sample_long_password_string",
      "remember_token": null,
      "created_at": "2018-01-01 10:00:00",
      "updated_at": "2018-01-01 10:00:00",
  ],
]

(GET) http://ID_ADDR/plain/files/csv (GET) http://ID_ADDR/plain/files/css (GET) http://ID_ADDR/plain/files/js (GET) http://ID_ADDR/plain/files/png (GET) http://ID_ADDR/plain/cookies

-> Basic auth

(GET) http://IP_ADDR/basi-auth

Sample response:

 [
    "status": "ok"
 ]

-> oAuth2 Endpoints

(POST) http://IP_ADDR/oauth2/token

> Form params: > - grant_type(optional): password, client_credentials > - client_id: string > - client_secret: string > - username: string > - password: string > - scope(optional): string > > Seeds: > - Password grant client > - client_id: 10 > - client_secret: F0NVue12qNwayx3pKJLHfJmQouOZg40YZafjjdHZ

(GET) http://ID_ADDR/oauth2/users - Return list of users.

>Headers: > - Content-Type: application/json > - Authorization: Bearer ACCESS_TOKEN > >

Sample response:

[
  [
      "id": 1,
      "name": "Sample name",
      "email": "sample@email.com",
      "password": "sample_long_password_string",
      "remember_token": null,
      "created_at": "2018-01-01 10:00:00",
      "updated_at": "2018-01-01 10:00:00",
  ],
  [
      "id": 2,
      "name": "Sample name",
      "email": "another@email.com",
      "password": "sample_long_password_string",
      "remember_token": null,
      "created_at": "2018-01-01 10:00:00",
      "updated_at": "2018-01-01 10:00:00",
  ],
]
  Files folder image Files  
File Role Description
Files folder imageDocker (5 files)
Files folder imageserver (9 files, 7 directories)
Files folder imagetests (2 files, 1 directory)
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file Makefile Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  Docker  
File Role Description
  Accessible without login Plain text file cli.docker Data Auxiliary data
  Accessible without login Plain text file docker.yml Data Auxiliary data
  Accessible without login Plain text file fpm.docker Data Auxiliary data
  Accessible without login Plain text file mysite.template Data Auxiliary data
  Accessible without login Plain text file nginx.docker Data Auxiliary data

  Files folder image Files  /  server  
File Role Description
Files folder imageapp (1 file, 4 directories)
Files folder imagebootstrap (1 file)
Files folder imageconfig (13 files)
Files folder imagedatabase (3 directories)
Files folder imagepublic (3 files, 2 directories)
Files folder imageresources (4 directories)
Files folder imageroutes (3 files)
  Accessible without login Plain text file .env Data Auxiliary data
  Accessible without login Plain text file .env.example Data Auxiliary data
  Plain text file artisan Class Class source
  Accessible without login Plain text file composer.json Data Auxiliary data
  Accessible without login Plain text file package.json Data Auxiliary data
  Accessible without login Plain text file phpunit.xml Data Auxiliary data
  Accessible without login Plain text file server.php Aux. Auxiliary script
  Accessible without login Plain text file webpack.mix.js Data Auxiliary data
  Accessible without login Plain text file yarn.lock Data Auxiliary data

  Files folder image Files  /  server  /  app  
File Role Description
Files folder imageConsole (1 file)
Files folder imageExceptions (1 file)
Files folder imageHttp (1 file, 1 directory)
Files folder imageProviders (5 files)
  Plain text file User.php Class Class source

  Files folder image Files  /  server  /  app  /  Console  
File Role Description
  Plain text file Kernel.php Class Class source

  Files folder image Files  /  server  /  app  /  Exceptions  
File Role Description
  Plain text file Handler.php Class Class source

  Files folder image Files  /  server  /  app  /  Http  
File Role Description
Files folder imageMiddleware (6 files)
  Plain text file Kernel.php Class Class source

  Files folder image Files  /  server  /  app  /  Http  /  Middleware  
File Role Description
  Plain text file AuthenticateOnceWithBasicAuth.php Class Class source
  Plain text file EncryptCookies.php Class Class source
  Plain text file RedirectIfAuthenticated.php Class Class source
  Plain text file TrimStrings.php Class Class source
  Plain text file TrustProxies.php Class Class source
  Plain text file VerifyCsrfToken.php Class Class source

  Files folder image Files  /  server  /  app  /  Providers  
File Role Description
  Plain text file AppServiceProvider.php Class Class source
  Plain text file AuthServiceProvider.php Class Class source
  Plain text file BroadcastServiceProvider.php Class Class source
  Plain text file EventServiceProvider.php Class Class source
  Plain text file RouteServiceProvider.php Class Class source

  Files folder image Files  /  server  /  bootstrap  
File Role Description
  Plain text file app.php Class Class source

  Files folder image Files  /  server  /  config  
File Role Description
  Plain text file app.php Class Class source
  Plain text file auth.php Class Class source
  Accessible without login Plain text file broadcasting.php Aux. Auxiliary script
  Accessible without login Plain text file cache.php Aux. Auxiliary script
  Accessible without login Plain text file database.php Aux. Auxiliary script
  Accessible without login Plain text file filesystems.php Aux. Auxiliary script
  Accessible without login Plain text file hashing.php Aux. Auxiliary script
  Accessible without login Plain text file logging.php Aux. Auxiliary script
  Accessible without login Plain text file mail.php Aux. Auxiliary script
  Accessible without login Plain text file queue.php Aux. Auxiliary script
  Plain text file services.php Class Class source
  Accessible without login Plain text file session.php Aux. Auxiliary script
  Accessible without login Plain text file view.php Aux. Auxiliary script

  Files folder image Files  /  server  /  database  
File Role Description
Files folder imagefactories (1 file)
Files folder imagemigrations (1 file)
Files folder imageseeds (3 files)

  Files folder image Files  /  server  /  database  /  factories  
File Role Description
  Plain text file UserFactory.php Class Class source

  Files folder image Files  /  server  /  database  /  migrations  
File Role Description
  Plain text file 2014_10_12_000000_create_users_table.php Class Class source

  Files folder image Files  /  server  /  database  /  seeds  
File Role Description
  Plain text file DatabaseSeeder.php Class Class source
  Plain text file OAuthSeeder.php Class Class source
  Plain text file UsersSeeder.php Class Class source

  Files folder image Files  /  server  /  public  
File Role Description
Files folder imagecss (1 file)
Files folder imagejs (1 file)
  Accessible without login Plain text file .htaccess Data Auxiliary data
  Plain text file index.php Class Class source
  Accessible without login Plain text file robots.txt Doc. Documentation

  Files folder image Files  /  server  /  public  /  css  
File Role Description
  Accessible without login Plain text file app.css Data Auxiliary data

  Files folder image Files  /  server  /  public  /  js  
File Role Description
  Accessible without login Plain text file app.js Data Auxiliary data

  Files folder image Files  /  server  /  resources  
File Role Description
Files folder imageassets (3 directories)
Files folder imagecsv (1 file)
Files folder imagelang (1 directory)
Files folder imageviews (1 file)

  Files folder image Files  /  server  /  resources  /  assets  
File Role Description
Files folder imagejs (2 files, 1 directory)
Files folder imagesample-files (4 files)
Files folder imagesass (2 files)

  Files folder image Files  /  server  /  resources  /  assets  /  js  
File Role Description
Files folder imagecomponents (1 file)
  Accessible without login Plain text file app.js Data Auxiliary data
  Accessible without login Plain text file bootstrap.js Data Auxiliary data

  Files folder image Files  /  server  /  resources  /  assets  /  js  /  components  
File Role Description
  Accessible without login Plain text file ExampleComponent.vue Data Auxiliary data

  Files folder image Files  /  server  /  resources  /  assets  /  sample-files  
File Role Description
  Accessible without login Plain text file sample.css Data Auxiliary data
  Accessible without login Plain text file sample.csv Data Auxiliary data
  Accessible without login Plain text file sample.js Data Auxiliary data
  Accessible without login Image file sample.png Icon Icon image

  Files folder image Files  /  server  /  resources  /  assets  /  sass  
File Role Description
  Accessible without login Plain text file app.scss Data Auxiliary data
  Accessible without login Plain text file _variables.scss Data Auxiliary data

  Files folder image Files  /  server  /  resources  /  csv  
File Role Description
  Accessible without login Plain text file users.csv Data Auxiliary data

  Files folder image Files  /  server  /  resources  /  lang  
File Role Description
Files folder imageen (4 files)

  Files folder image Files  /  server  /  resources  /  lang  /  en  
File Role Description
  Accessible without login Plain text file auth.php Aux. Auxiliary script
  Accessible without login Plain text file pagination.php Aux. Auxiliary script
  Accessible without login Plain text file passwords.php Aux. Auxiliary script
  Accessible without login Plain text file validation.php Aux. Auxiliary script

  Files folder image Files  /  server  /  resources  /  views  
File Role Description
  Accessible without login Plain text file welcome.blade.php Aux. Auxiliary script

  Files folder image Files  /  server  /  routes  
File Role Description
  Accessible without login Plain text file api.php Example Example script
  Accessible without login Plain text file channels.php Example Example script
  Accessible without login Plain text file console.php Example Example script

  Files folder image Files  /  tests  
File Role Description
Files folder imagetests (8 files, 2 directories)
  Accessible without login Plain text file composer.json Data Auxiliary data
  Accessible without login Plain text file rest-control.yml Data Auxiliary data

  Files folder image Files  /  tests  /  tests  
File Role Description
Files folder imageObjects (1 file)
Files folder imageServerResponses (2 files)
  Plain text file CookieTest.php Class Class source
  Plain text file ExpressionLanguageTest.php Class Class source
  Plain text file FilesTest.php Class Class source
  Plain text file HasItemsTest.php Class Class source
  Plain text file HasItemTest.php Class Class source
  Plain text file HttpBasicAuthTest.php Class Class source
  Plain text file HttpStatusCodesTest.php Class Class source
  Plain text file JsonPathTest.php Class Class source

  Files folder image Files  /  tests  /  tests  /  Objects  
File Role Description
  Plain text file UserObject.php Class Class source

  Files folder image Files  /  tests  /  tests  /  ServerResponses  
File Role Description
  Plain text file GetUser.php Class Class source
  Plain text file GetUsers.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:29
This week:1
All time:10,285
This week:182Up
For more information send a message to info at phpclasses dot org.