This project is a PHP web application built using the Slim framework. It includes features for user authentication, picture uploading, and API routing, along with error handling and routing.
- User authentication (registration, login, activation)
- Picture upload functionality
- API routing for user management and static content
- Custom error handling
- Environment configuration with Dotenv
- Dependency Injection with PHP-DI
- Middleware integration
- PHP 7.4 or higher
- Composer for dependency management
- Clone the repository:
git clone https://github.com/claserre9/slim-auth-jwt.git
- Install dependencies via Composer:
composer install
- Set up your environment variables in a
.env
file based on the example provided.
To start the application:
php -S localhost:8000 -t public
Navigate to http://localhost:8000
in your web browser to use the application.
src/controllers
: Contains controllers such asUploadController
andUserController
.src/handlers
: Error handling logic.src/middlewares
: Middleware for authentication and others.config
: Configuration files including container setup.
- POST
/auth/register
- User registration - POST
/auth/login
- User login - GET
/auth/activate
- User account activation - GET
/auth/activation/send
- Send activation token - POST
/auth/password/reset
- Password reset - POST
/auth/password/confirm
- Password reset confirmation - GET
/auth/refresh/token
- Token refresh - GET
/auth/me
- Get logged-in user information
- POST
/upload/picture
- Endpoint for picture uploads
- GET
/static/{path:.+}
- Endpoint for serving static content
$app->post('/upload/picture', [UploadController::class, 'upload'])->add(new AuthMiddleware());
Custom error handling is set up to manage application exceptions and provide useful feedback.
$errorHandler = new HttpErrorHandler($app->getCallableResolver(), $app->getResponseFactory());
$app->addErrorMiddleware(true, true, true)
->setDefaultErrorHandler($errorHandler);
We welcome contributions to this project! If you would like to contribute, please follow these steps:
-
Fork the Repository: Create a copy of this project on your GitHub account by forking it.
-
Clone the Forked Repository: Clone the forked repository to your local machine.
git clone [your-forked-repository-url]
-
Create a New Branch: Create a new branch for your modifications.
git checkout -b [your-branch-name]
-
Make Your Changes: Implement your changes or improvements in your branch.
-
Commit and Push Your Changes: After making changes, commit them to your branch and push them to your fork.
git commit -am "Add some feature" git push origin [your-branch-name]
-
Create a Pull Request: Go to the original repository and create a pull request from your branch. Please provide a clear description of your changes and the purpose of them.
We look forward to your contributions!
This project is licensed under the MIT License.