This is a simple chat application backend written in PHP using the Slim Framework. Users can create chat groups, join these groups, and send messages within them. The data is stored in an SQLite database, and communication between the client and server happens over a RESTful JSON API over HTTP(s).
- PHP
- Composer
- SQLite
- Clone the repository.
- Run
composer install
to install the dependencies. - Run
php -S localhost:8888 -t public
to start the server.
You can also find JSON collection in /docs directory.
-
Register:
- Endpoint:
POST /api/register
- Description: Create a new user.
- Request Body:
first_name
: Firstname of the user.last_name
: Surname of the user.email
: Email of the user.password
: Password of the user.
- Endpoint:
-
Login:
- Endpoint:
POST /api/login
- Description: Login as a user.
- Request Body:
email
: Email of the user.password
: Password of the user.
- Endpoint:
-
Create a Group:
- Endpoint:
POST /api/groups
- Description: Create a new chat group.
- Request Body:
name
: The name of the group.
- Endpoint:
-
List of all Groups:
- Endpoint:
GET /api/groups
- Description: Retrieve a list of all available chat groups.
- Endpoint:
-
Join a Group:
- Endpoint:
POST /api/groups/{group_id}/join
- Description: Allow the user to join a specific chat group.
- Header:
Authorization
: The user's Bearer JWT token.
- Endpoint:
-
List Messages in a Group:
- Endpoint:
GET /api/groups/{group_id}/messages
- Description: Retrieve all messages within a specific chat group.
- Header:
Authorization
: The user's Bearer JWT token.
- Endpoint:
-
Send a Message:
- Endpoint:
POST /api/groups/{group_id}/messages
- Description: Send a message to a specific chat group.
- Request Body:
content
: Content of the message.
- Header:
Authorization
: The user's Bearer JWT token.
- Endpoint:
./vendor/bin/phpunit tests/RegisterControllerTest.php; ./vendor/bin/phpunit tests/LoginControllerTest.php; ./vendor/bin/phpunit tests/GroupControllerTest.php
- Hardcoded values were used in some tests.
Feel free to contribute to the development of this project by opening issues or submitting pull requests.