PHP Chat API: Exchange chat messages between users using an API

Recommend this page to a friend!
  Info   Documentation   View files (82)   Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2020-07-02 (1 month ago) Not yet rated by the usersTotal: 103 This week: 2All time: 9,339 This week: 110
Version License PHP version Categories
chat_api 1.0.0The PHP License5PHP 5, Web services, Chat
Description Author

This package can be used to exchange chat messages between users using an API.

It provides an API that with function end points to perform operations for implementing a chat system. Currently the API implements operations to:

- Authenticate a chat user
- Send a message from a user to another user
- Retrieve messages for a given user

Innovation Award
PHP Programming Innovation award nominee
July 2020
Nominee
Vote
Many sites need a chat system to allow exchanging message between users or chat with the site support people.

This package implements an API for a chat system that can be used to exchange messages between people on a regular browser using JavaScript or a mobile version of the site application to communicate with the API.

Manuel Lemos
Picture of uche
Name: uche <contact>
Classes: 2 packages by
Country: Nigeria Nigeria
Age: ???
All time rank: 410833 in Nigeria Nigeria
Week rank: 34 4 in Nigeria Nigeria
Innovation award
Innovation award
Nominee: 2x

Details

Backend Chat API

A backend Chat API written in Laravel with these features:

  • Users can send and receive messages
  • Users are authenticated in order to send and retrieve messages using Laravel Passport
  • Uses cache system to increase speed of message retrieval
  • Feature tests written to assert users can login, send messages and retrieve messages

How to use

  • Clone project
  • Run composer install
  • Add .env file and specify credentials for cache and database (if needed)
  • Run php artisan migrate for migrations
  • Run php artisan db:seed to seed users
  • Run php artisan passport:install for laravel passport
  • Test endpoints

Endpoints

  • Login User - /api/auth/login [POST]

    Sample body - { "username":"john", "password":"password" }

  • Send Message - /api/messages [POST] Sample body - { "message":"hello world", "receiver_username":"john" } > This endpoint uses bearer token gotten from login endpoint
  • Retrieve Message - /api/messages [GET] > This endpoint uses bearer token gotten from login endpoint

Testing

Run the feature test - vender/bin/phpunit

  Files  
File Role Description
app (2 files, 7 directories)
bootstrap (1 file)
config (14 files)
database (3 directories)
public (4 files)
resources (4 directories)
routes (4 files)
tests (2 files, 2 directories)
.editorconfig Data Auxiliary data
.env.example Data Auxiliary data
.styleci.yml Data Auxiliary data
artisan Class Class source
composer.json Data Auxiliary data
composer.lock Data Auxiliary data
package.json Data Auxiliary data
phpunit.xml Data Auxiliary data
README.md Doc. Documentation
server.php Aux. Auxiliary script
webpack.mix.js Data Auxiliary data

  Files  /  app  
File Role Description
Console (1 file)
Exceptions (1 file)
Http (1 file, 4 directories)
Observers (1 file)
Providers (5 files)
Rules (1 file)
Services (2 files)
   Message.php Class Class source
   User.php Class Class source

  Files  /  app  /  Console  
File Role Description
   Kernel.php Class Class source

  Files  /  app  /  Exceptions  
File Role Description
   Handler.php Class Class source

  Files  /  app  /  Http  
File Role Description
Controllers (3 files)
Middleware (9 files)
Requests (1 file)
Resources (1 file)
   Kernel.php Class Class source

  Files  /  app  /  Http  /  Controllers  
File Role Description
   AuthController.php Class Class source
   Controller.php Class Class source
   MessageController.php Class Class source

  Files  /  app  /  Http  /  Middleware  
File Role Description
   Authenticate.php Class Class source
   CheckApiToken.php Class Class source
   CheckForMaintenanceMode.php Class Class source
   EncryptCookies.php Class Class source
   RedirectIfAuthenticated.php Class Class source
   TrimStrings.php Class Class source
   TrustHosts.php Class Class source
   TrustProxies.php Class Class source
   VerifyCsrfToken.php Class Class source

  Files  /  app  /  Http  /  Requests  
File Role Description
   MessageRequest.php Class Class source

  Files  /  app  /  Http  /  Resources  
File Role Description
   MessageResource.php Class Class source

  Files  /  app  /  Observers  
File Role Description
   MessageObserver.php Class Class source

  Files  /  app  /  Providers  
File Role Description
   AppServiceProvider.php Class Class source
   AuthServiceProvider.php Class Class source
   BroadcastServiceProvider.php Class Class source
   EventServiceProvider.php Class Class source
   RouteServiceProvider.php Class Class source

  Files  /  app  /  Rules  
File Role Description
   ValidateUsername.php Class Class source

  Files  /  app  /  Services  
File Role Description
   CacheService.php Class Class source
   MessageService.php Class Class source

  Files  /  bootstrap  
File Role Description
   app.php Class Class source

  Files  /  config  
File Role Description
   app.php Class Class source
   auth.php Class Class source
   broadcasting.php Aux. Auxiliary script
   cache.php Aux. Auxiliary script
   cors.php Aux. Auxiliary script
   database.php Aux. Auxiliary script
   filesystems.php Aux. Auxiliary script
   hashing.php Aux. Auxiliary script
   logging.php Class Class source
   mail.php Aux. Auxiliary script
   queue.php Aux. Auxiliary script
   services.php Aux. Auxiliary script
   session.php Aux. Auxiliary script
   view.php Aux. Auxiliary script

  Files  /  database  
File Role Description
factories (1 file)
migrations (3 files)
seeds (2 files)

  Files  /  database  /  factories  
File Role Description
   UserFactory.php Class Class source

  Files  /  database  /  migrations  
File Role Description
   2019_08_19_000000_...iled_jobs_table.php Class Class source
   2020_06_25_101224_create_users_table.php Class Class source
   2020_06_25_164825_...e_message_table.php Class Class source

  Files  /  database  /  seeds  
File Role Description
   DatabaseSeeder.php Class Class source
   UserSeeder.php Class Class source

  Files  /  public  
File Role Description
   .htaccess Data Auxiliary data
   index.php Class Class source
   robots.txt Doc. Documentation
   web.config Data Auxiliary data

  Files  /  resources  
File Role Description
js (2 files)
lang (1 directory)
sass (1 file)
views (1 file)

  Files  /  resources  /  js  
File Role Description
   app.js Data Auxiliary data
   bootstrap.js Data Auxiliary data

  Files  /  resources  /  lang  
File Role Description
en (4 files)

  Files  /  resources  /  lang  /  en  
File Role Description
   auth.php Aux. Auxiliary script
   pagination.php Aux. Auxiliary script
   passwords.php Aux. Auxiliary script
   validation.php Aux. Auxiliary script

  Files  /  resources  /  sass  
File Role Description
   app.scss Data Auxiliary data

  Files  /  resources  /  views  
File Role Description
   welcome.blade.php Aux. Auxiliary script

  Files  /  routes  
File Role Description
   api.php Example Example script
   channels.php Example Example script
   console.php Example Example script
   web.php Aux. Auxiliary script

  Files  /  tests  
File Role Description
Feature (3 files)
Unit (1 file)
   CreatesApplication.php Class Class source
   TestCase.php Class Class source

  Files  /  tests  /  Feature  
File Role Description
   ExampleTest.php Class Class source
   LoginTest.php Class Class source
   MessageTest.php Class Class source

  Files  /  tests  /  Unit  
File Role Description
   ExampleTest.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:103
This week:2
All time:9,339
This week:110

For more information send a message to info at phpclasses dot org.