A modern RESTful API service built with Laravel for managing blog posts, comments, and user authentication. This project serves as a backend for the NoteBin Flutter application.
- π User Authentication (Register/Login)
- π Blog Post Management (CRUD)
- π¬ Comment System
- π€ File Upload Support
- π Secure API Endpoints
- Clone the repository
- Run
composer install - Copy
.env.exampleto.envand configure - Run
php artisan key:generate - Run
php artisan migrate - Start server with
php artisan serve
- POST
/register- User registration - POST
/login- User login - POST
/logout- User logout
- GET
/posts- List all posts - POST
/posts- Create post - GET
/posts/{id}- Get post - PUT
/posts/{id}- Update post - DELETE
/posts/{id}- Delete post
- GET
/comments- List all comments - POST
/comments- Create comment - GET
/comments/{id}- Get comment - PUT
/comments/{id}- Update comment - DELETE
/comments/{id}- Delete comment
This project is licensed under the MIT License - see the LICENSE file for details.
Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:
This project aims to provide a robust RESTful API service using the Laravel framework. The primary purpose is to facilitate the management of posts and comments, along with user authentication functionalities. By leveraging Laravel's features, such as routing, controllers, and middleware, the project aims to offer a secure and efficient API for developers to integrate into their applications. The goal is to streamline the process of creating, retrieving, updating, and deleting posts and comments, while also ensuring secure user authentication and authorization.
Before you begin, ensure that you have the necessary software installed on your machine. You'll need:
- PHP
- Composer
- Git
Move into the project directory using the cd command:
cd repository
Replace repository with the actual name of the cloned repository.
Run the following command to install the project dependencies using Composer:
composer install
This command will download and install all the required packages specified in the composer.json file.
Duplicate the .env.example file and save it as .env:
cp .env.example .env
Open the .env file and configure the database connection and any other necessary settings.
Generate the application key using the following command:
php artisan key:generate
This key is used for encrypting user sessions and other sensitive data.
Execute the following command to run the database migrations:
php artisan migrate
This command will create the necessary database tables based on the migration files.
To run the Laravel development server, use the following command:
php artisan serve
To demonstrate the usage of this API service, a Flutter application has been developed as a note-taking app. This Flutter app seamlessly integrates with the provided Laravel-based API endpoints to offer users the ability to create, read, update, and delete notes. Additionally, users can add comments to individual notes, providing a collaborative environment for note management. The Flutter app showcases the versatility and ease of integration with the API service, providing a real-world example of how developers can leverage the Laravel back-end to power their mobile applications. Explore the codebase of the Flutter app to see how it communicates with the Laravel API and handles various API requests and responses.
link project:
https://github.com/arminmehraeen/NoteBin
- POST /register: Endpoint for user registration.
- POST /login: Endpoint for user login.
- GET /user: Fetches the authenticated user's information.
- POST /logout: Logs out the authenticated user.
- POST /upload: Endpoint for uploading files. Requires authentication.
- GET /posts: Lists all posts.
- POST /posts: Creates a new post.
- GET /posts/{post}: Fetches a specific post.
- PUT /posts/{post}: Updates a specific post.
- DELETE /posts/{post}: Deletes a specific post.
- GET /comments: Lists all comments.
- POST /comments: Creates a new comment.
- GET /comments/{comment}: Fetches a specific comment.
- PUT /comments/{comment}: Updates a specific comment.
- DELETE /comments/{comment}: Deletes a specific comment.
- auth:sanctum: Middleware that ensures routes are accessible only to authenticated users.
LoginRegisterController: Handles registration, login, fetching user information, and logout.UploadController: Handles file uploads.PostController: Manages CRUD operations for posts.CommentController: Manages CRUD operations for comments.
The Laravel framework is open-sourced software licensed under the MIT license.