{"id":26794542,"url":"https://github.com/dzulkifli578/sanctum-post-app","last_synced_at":"2025-03-29T17:27:59.656Z","repository":{"id":268501535,"uuid":"904551376","full_name":"dzulkifli578/sanctum-post-app","owner":"dzulkifli578","description":"Sanctum Post App is a simple Laravel project using Laravel Sanctum to manage user authentication and CRUD operations for posts. This app serves as a personal guide for implementing authentication in future projects.","archived":false,"fork":false,"pushed_at":"2024-12-17T06:16:53.000Z","size":0,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-17T06:30:31.927Z","etag":null,"topics":["api","authentication","crud","laravel","php","sanctum"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dzulkifli578.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-12-17T05:40:04.000Z","updated_at":"2024-12-17T06:22:01.000Z","dependencies_parsed_at":"2024-12-17T06:40:44.673Z","dependency_job_id":null,"html_url":"https://github.com/dzulkifli578/sanctum-post-app","commit_stats":null,"previous_names":["dzulkifli578/sanctum-post-app"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dzulkifli578%2Fsanctum-post-app","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dzulkifli578%2Fsanctum-post-app/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dzulkifli578%2Fsanctum-post-app/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dzulkifli578%2Fsanctum-post-app/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dzulkifli578","download_url":"https://codeload.github.com/dzulkifli578/sanctum-post-app/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246218364,"owners_count":20742364,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","authentication","crud","laravel","php","sanctum"],"created_at":"2025-03-29T17:27:59.135Z","updated_at":"2025-03-29T17:27:59.650Z","avatar_url":"https://github.com/dzulkifli578.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Sanctum Post App\n\n\u003cp align=\"center\"\u003e\u003ca href=\"https://laravel.com\" target=\"_blank\"\u003e\u003cimg src=\"https://raw.githubusercontent.com/laravel/art/master/logo-lockup/5%20SVG/2%20CMYK/1%20Full%20Color/laravel-logolockup-cmyk-red.svg\" width=\"400\" alt=\"Laravel Logo\"\u003e\u003c/a\u003e\u003c/p\u003e\n\n## Project Description\n\n\nSanctum Post App is a simple project created to store learning outcomes using **Laravel Sanctum** and serves as a personal guide for future projects related to authentication.\n\n### Project Goals:\n\n-   Provide a guide for authentication using Laravel Sanctum.\n-   Offer features such as **Register**, **Login**, **Logout**, and **CRUD Post**.\n\n-   Provide a guide for authentication using Laravel Sanctum.\n-   Offer features such as **Register**, **Login**, **Logout**, and **CRUD Post**.\n\n### Problems Addressed:\n\n-   Currently, there are no specific issues to solve other than completing unfinished features.\n\n-   Currently, there are no specific issues to solve other than completing unfinished features.\n\n### Key Features:\n\n-   **User Authentication**\n    -   Register\n    -   Login\n    -   Logout\n-   **CRUD Post**\n    -   Create Post\n    -   Read Post\n    -   Update Post\n    -   Delete Post\n\n-   **User Authentication**\n    -   Register\n    -   Login\n    -   Logout\n-   **CRUD Post**\n    -   Create Post\n    -   Read Post\n    -   Update Post\n    -   Delete Post\n\n---\n\n## Prerequisites\n\n\nBefore installing and running this project, ensure you have the following software installed:\n\n-   **PHP**: Version 8.3.9 or newer.\n-   **Composer**: For managing Laravel dependencies.\n-   **PostgreSQL**: The database used.\n-   **PHP**: Version 8.3.9 or newer.\n-   **Composer**: For managing Laravel dependencies.\n-   **PostgreSQL**: The database used.\n\n### Additional Configuration:\n\n-   Set up the **.env** configuration file to match your local database setup.\n\n-   Set up the **.env** configuration file to match your local database setup.\n\nThis project **does not require any external services** or other special configurations beyond the above.\n\n---\n\n## Installation Instructions\n\n\nFollow the steps below to install and run the project in a local environment:\n\n1. **Clone the repository**:\n\n    ```bash\n    git clone \u003crepository-url\u003e\n    cd sanctum-post-app\n    ```\n\n    ```bash\n    git clone \u003crepository-url\u003e\n    cd sanctum-post-app\n    ```\n\n2. **Install dependencies using Composer**:\n\n    ```bash\n    composer install\n    ```\n\n    ```bash\n    composer install\n    ```\n\n3. **Prepare the .env file**:\n\n    - Duplicate the `.env.example` file as `.env`.\n    - Set up the database connection to match your PostgreSQL setup:\n        ```dotenv\n        DB_CONNECTION=pgsql\n        DB_HOST=127.0.0.1\n        DB_PORT=5432\n        DB_DATABASE=your_database_name\n        DB_USERNAME=your_database_user\n        DB_PASSWORD=your_database_password\n        ```\n\n    - Duplicate the `.env.example` file as `.env`.\n    - Set up the database connection to match your PostgreSQL setup:\n        ```dotenv\n        DB_CONNECTION=pgsql\n        DB_HOST=127.0.0.1\n        DB_PORT=5432\n        DB_DATABASE=your_database_name\n        DB_USERNAME=your_database_user\n        DB_PASSWORD=your_database_password\n        ```\n\n4. **Run database migrations**:\n\n    ```bash\n    php artisan migrate\n    ```\n\n    ```bash\n    php artisan migrate\n    ```\n\n5. **Start the application server**:\n\n    ```bash\n    php artisan serve\n    ```\n\n    ```bash\n    php artisan serve\n    ```\n\n6. **Test the application**:\n   Use Postman or any API testing tool to access:\n    ```\n    http://127.0.0.1:8000/api/test\n    ```\n    ```\n    http://127.0.0.1:8000/api/test\n    ```\n\n---\n\n## Application Usage\n\n\n### Running the Application\n\n\nThe application can be accessed using Postman or any other API client.\n\n### API Endpoint URLs\n\n\nBelow are the available API endpoints:\n\n1. **CSRF Cookie**\n\n    - Method: `GET`\n    - URL: `http://localhost:8000/sanctum/csrf-cookie`\n\n    - Method: `GET`\n    - URL: `http://localhost:8000/sanctum/csrf-cookie`\n\n2. **Decrypt CSRF Cookie**\n\n    - Method: `GET`\n    - URL: `http://localhost:8000/api/decrypt`\n    - Header:\n        - `X-XSRF-TOKEN`: `\u003ctoken\u003e`\n\n    - Method: `GET`\n    - URL: `http://localhost:8000/api/decrypt`\n    - Header:\n        - `X-XSRF-TOKEN`: `\u003ctoken\u003e`\n\n3. **Authentication**\n\n    - **Register**\n        - Method: `POST`\n        - URL: `http://localhost:8000/api/register`\n        - Header:\n            - `Accept`: `application/json`\n            - `X-XSRF-TOKEN`: `\u003ctoken\u003e`\n        - Body:\n            ```json\n            {\n                \"name\": \"Dzulkifli Anwar\",\n                \"email\": \"dzul@gmail.com\",\n                \"password\": \"123456\"\n            }\n            ```\n    - **Login**\n        - Method: `POST`\n        - URL: `http://localhost:8000/api/login`\n        - Header:\n            - `Accept`: `application/json`\n            - `X-XSRF-TOKEN`: `\u003ctoken\u003e`\n        - Body:\n            ```json\n            {\n                \"email\": \"dzul@gmail.com\",\n                \"password\": \"123456\"\n            }\n            ```\n    - **Profile**\n        - Method: `GET`\n        - URL: `http://localhost:8000/api/profile`\n        - Header:\n            - `Authorization`: `Bearer \u003ctoken\u003e`\n    - **Logout**\n        - Method: `POST`\n        - URL: `http://localhost:8000/api/logout`\n        - Header:\n            - `X-XSRF-TOKEN`: `\u003ctoken\u003e`\n            - `Authorization`: `Bearer \u003ctoken\u003e`\n\n    - **Register**\n        - Method: `POST`\n        - URL: `http://localhost:8000/api/register`\n        - Header:\n            - `Accept`: `application/json`\n            - `X-XSRF-TOKEN`: `\u003ctoken\u003e`\n        - Body:\n            ```json\n            {\n                \"name\": \"Dzulkifli Anwar\",\n                \"email\": \"dzul@gmail.com\",\n                \"password\": \"123456\"\n            }\n            ```\n    - **Login**\n        - Method: `POST`\n        - URL: `http://localhost:8000/api/login`\n        - Header:\n            - `Accept`: `application/json`\n            - `X-XSRF-TOKEN`: `\u003ctoken\u003e`\n        - Body:\n            ```json\n            {\n                \"email\": \"dzul@gmail.com\",\n                \"password\": \"123456\"\n            }\n            ```\n    - **Profile**\n        - Method: `GET`\n        - URL: `http://localhost:8000/api/profile`\n        - Header:\n            - `Authorization`: `Bearer \u003ctoken\u003e`\n    - **Logout**\n        - Method: `POST`\n        - URL: `http://localhost:8000/api/logout`\n        - Header:\n            - `X-XSRF-TOKEN`: `\u003ctoken\u003e`\n            - `Authorization`: `Bearer \u003ctoken\u003e`\n\n4. **CRUD Post**\n    - **Create Post**\n        - Method: `POST`\n        - URL: `http://localhost:8000/api/post/`\n        - Header:\n            - `Accept`: `application/json`\n            - `X-XSRF-TOKEN`: `\u003ctoken\u003e`\n            - `Authorization`: `Bearer \u003ctoken\u003e`\n        - Body:\n            ```json\n            {\n                \"title\": \"Title 1\",\n                \"body\": \"Body 1\",\n                \"user_id\": 1\n            }\n            ```\n    - **Read Posts**\n        - Method: `GET`\n        - URL: `http://localhost:8000/api/post/`\n        - Header:\n            - `Authorization`: `Bearer \u003ctoken\u003e`\n    - **Update Post**\n        - Method: `PUT`\n        - URL: `http://localhost:8000/api/post/{id}`\n        - Header:\n            - `Accept`: `application/json`\n            - `X-XSRF-TOKEN`: `\u003ctoken\u003e`\n            - `Authorization`: `Bearer \u003ctoken\u003e`\n        - Body:\n            ```json\n            {\n                \"title\": \"Title 1\",\n                \"body\": \"Body 1\",\n                \"user_id\": 1\n            }\n            ```\n    - **Delete Post**\n        - Method: `DELETE`\n        - URL: `http://localhost:8000/api/post/{id}`\n        - Header:\n            - `X-XSRF-TOKEN`: `\u003ctoken\u003e`\n            - `Authorization`: `Bearer \u003ctoken\u003e`\n    - **Create Post**\n        - Method: `POST`\n        - URL: `http://localhost:8000/api/post/`\n        - Header:\n            - `Accept`: `application/json`\n            - `X-XSRF-TOKEN`: `\u003ctoken\u003e`\n            - `Authorization`: `Bearer \u003ctoken\u003e`\n        - Body:\n            ```json\n            {\n                \"title\": \"Title 1\",\n                \"body\": \"Body 1\",\n                \"user_id\": 1\n            }\n            ```\n    - **Read Posts**\n        - Method: `GET`\n        - URL: `http://localhost:8000/api/post/`\n        - Header:\n            - `Authorization`: `Bearer \u003ctoken\u003e`\n    - **Update Post**\n        - Method: `PUT`\n        - URL: `http://localhost:8000/api/post/{id}`\n        - Header:\n            - `Accept`: `application/json`\n            - `X-XSRF-TOKEN`: `\u003ctoken\u003e`\n            - `Authorization`: `Bearer \u003ctoken\u003e`\n        - Body:\n            ```json\n            {\n                \"title\": \"Title 1\",\n                \"body\": \"Body 1\",\n                \"user_id\": 1\n            }\n            ```\n    - **Delete Post**\n        - Method: `DELETE`\n        - URL: `http://localhost:8000/api/post/{id}`\n        - Header:\n            - `X-XSRF-TOKEN`: `\u003ctoken\u003e`\n            - `Authorization`: `Bearer \u003ctoken\u003e`\n\n---\n\n## Project Structure\n\n\nThe project directory structure follows the standard Laravel layout with additional **interface** and **service** folders under `app`:\n\n```\napp/\n├── Http/\n│   ├── Controllers/\n│   │   └── Api/\n│   │       ├── AuthController.php\n│   │       └── PostController.php\n│   └── Resources/\n│       ├── PostResource.php\n│       └── UserResource.php\n├── Interfaces/\n│   ├── AuthControllerInterface.php\n│   ├── AuthServiceInterface.php\n│   ├── PostControllerInterface.php\n│   └── PostServiceInterface.php\n├── Services/\n│   ├── AuthService.php\n│   └── PostService.php\n...\n```\n\n---\n\n## Contributions\n\n\nContributions are welcome! However, the contribution guidelines are not yet ready and will be provided in the future. Please stay tuned for updates.\n\n---\n\n## License\n\n\nThis project is licensed under the **MIT License**. Please refer to the license file for more information.\n\n---\n\n## Testing\n\n\nTesting for this project is conducted manually using Postman or other API testing tools.\n\n---\n\n## Known Issues\n\n-   **Unfinished Features**:\n    -   Edit user profile.\n-   No other known issues or bugs at this time.\n\n-   **Unfinished Features**:\n    -   Edit user profile.\n-   No other known issues or bugs at this time.\n\n---\n\n## Contact and Support\n\n\nIf you encounter any issues or have questions about this project, feel free to contact:\n\n-   **Name**: Dzulkifli Anwar\n-   **Email**: [ad875.darkroom373@passinbox.com](mailto:ad875.darkroom373@passinbox.com)\n-   **Telegram**: [@dzul_578](https://t.me/dzul_578)\n-   **Name**: Dzulkifli Anwar\n-   **Email**: [ad875.darkroom373@passinbox.com](mailto:ad875.darkroom373@passinbox.com)\n-   **Telegram**: [@dzul_578](https://t.me/dzul_578)\n\n---\n\n## References\n\n\nThis project is based on a YouTube learning playlist with code adjustments:\n\n-   [Learn Laravel Sanctum](https://www.youtube.com/playlist?list=PLaVebpbEIP3bbdPv_67BzjiYpiHWJyv9E)\n\n-   [Learn Laravel Sanctum](https://www.youtube.com/playlist?list=PLaVebpbEIP3bbdPv_67BzjiYpiHWJyv9E)\n\n---\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdzulkifli578%2Fsanctum-post-app","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdzulkifli578%2Fsanctum-post-app","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdzulkifli578%2Fsanctum-post-app/lists"}