This repository contains a Laravel 11-based API for a File Management System (FMS). The system enables users to upload, retrieve, update, and delete files seamlessly, along with managing associated metadata.
- RESTful API endpoints.
- File upload to Synology NAS with validation.
- Metadata management (e.g., file name, size, and type).
- File retrieval and download.
- File update and replacement.
- File deletion.
- PHP 8.1 or later
- Composer
- Laravel 11
- MySQL or any other database supported by Laravel
- Node.js (for frontend dependencies if applicable)
-
Clone the repository:
git clone https://github.com/rabucejojr/laravel-api.git cd laravel-api
-
Install dependencies:
composer install npm install
-
Configure environment variables:
- Copy
.env.example
to.env
:cp .env.example .env
- Update
.env
with your database and other configurations.
- Copy
-
Generate the application key:
php artisan key:generate
-
Run migrations:
php artisan migrate
-
(Optional) Seed the database:
php artisan db:seed
php artisan serve
The API will be available at http://127.0.0.1:8000
.
- GET
/api/files
- List all files. - GET
/api/files/{id}
- Retrieve a specific file. - POST
/api/files
- Upload a new file.- Parameters:
name
(string): Name of the file.file
(file): The file to upload.
- Parameters:
- PUT
/api/files/{id}
- Update file metadata or replace the file.- Parameters:
name
(string): Updated name of the file.file
(file): New file to replace the existing one.
- Parameters:
- DELETE
/api/files/{id}
- Delete a file.
- File uploads are validated to ensure:
- File size is within 10MB.
- File type is one of the allowed MIME types (e.g.,
image/png
,application/pdf
).
- Both
name
andfile
fields are required for uploads and updates.
Run tests using PHPUnit:
php artisan test
This API is designed to work with any frontend framework (e.g., Vue.js, React). For a Laravel + Inertia.js implementation, ensure routes are properly configured.
Contributions are welcome! Please fork this repository and submit a pull request with your improvements.
For any inquiries or support, please contact [[email protected]].