Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/techlord001/laravel-blog
Laravel project to showcase my skills & knowledge in the framework. This is a working blog with user sign/login and CRUD operations for the blog.
https://github.com/techlord001/laravel-blog
blade crud laravel php
Last synced: 14 days ago
JSON representation
Laravel project to showcase my skills & knowledge in the framework. This is a working blog with user sign/login and CRUD operations for the blog.
- Host: GitHub
- URL: https://github.com/techlord001/laravel-blog
- Owner: techlord001
- Created: 2023-10-08T08:50:47.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2023-10-13T08:42:55.000Z (about 1 year ago)
- Last Synced: 2024-11-07T05:37:22.568Z (2 months ago)
- Topics: blade, crud, laravel, php
- Language: PHP
- Homepage:
- Size: 101 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Laravel Blog Project
---
### Introduction
This Laravel blog project is a comprehensive application for creating, viewing, editing, and deleting blog posts. It is built with Laravel, a PHP web application framework that is known for its elegant syntax and rich features. This README provides an overview of the code structure, explains how the code works, highlights the Laravel features utilized in this project, and provides instructions on how to run tests and build the application.
### Code Overview
#### 1. Controllers
- **HomeController.php**
- Handles the application dashboard rendering, utilizing Laravel's authentication middleware to ensure access is granted to authenticated users only. The `index()` method retrieves the authenticated user's posts and passes them to the 'home' view.- **PostController.php**
- Manages CRUD operations for blog posts, employing the 'auth' middleware to restrict access, except for the 'index' and 'show' methods. Laravel's policy feature is in play for authorizing actions like creating, updating, and deleting posts.#### 2. Models
- **Post.php**
- Represents the Post entity, facilitating interactions with the posts table in the database using Laravel's Eloquent ORM. The model defines fillable attributes for mass assignment.- **User.php**
- Represents the User entity, equipped with traits for authentication and API tokens. It establishes a one-to-many relationship with the Post model.#### 3. Policies
- **PostPolicy.php**
- Outlines authorization policies for actions on the Post model, ensuring post owners have exclusive rights to update or delete.#### 4. Providers
- **AuthServiceProvider.php**
- Registers the PostPolicy and associates it with the Post model, integral to Laravel's authentication and authorization services.#### 5. Database
- **Factories and Seeders**
- Utilizes Laravel's factory and seeder for populating the database with sample data, with `PostFactory` and `DatabaseSeeder` being pivotal.#### 6. Views
- **home.blade.php and posts/*.blade.php**
- These Blade templates render the user interface, leveraging Laravel's Blade templating engine for seamless PHP code embedding within HTML.#### 7. Tests
- **PostControllerTest.php and PostTest.php**
- Contain tests for the PostController and Post model, employing Laravel's testing features for application reliability and integrity assurance.#### 8. Routes
- **web.php**
- Defines the application's web routes, exemplifying Laravel's expressive syntax for intuitive and readable route-to-controller action mapping.### Laravel Features Highlight
- **Authentication and Authorization**
- Extensive use of Laravel's in-built features for user authentication and authorization, with the 'auth' middleware and policy classes ensuring application security.- **Eloquent ORM**
- Eloquent facilitates convenient and elegant database interactions, with the Post and User models exemplifying its capabilities.- **Blade Templating Engine**
- The views are crafted using the Blade templating engine, enabling effortless PHP code integration within HTML.- **Testing**
- The application employs Laravel’s integrated testing features, ensuring component functionality and integrity.- **Routing**
- Laravel’s expressive routing syntax is showcased in the web.php file, enhancing route definition readability and intuitiveness.### Running Tests
To run the tests, follow these steps:
1. Navigate to the project's root directory in your terminal.
2. Run the following command to execute the tests:
```bash
php artisan test
```
This command will run all the tests in the `tests` directory and display the results in the terminal.### Building/Compiling the Application
1. Ensure you have Composer and NPM installed. If not, you can download and install them from [getcomposer.org](https://getcomposer.org/) and [npmjs.com](https://www.npmjs.com/), respectively.
2. Navigate to the project's root directory in your terminal.
3. Install PHP dependencies by running:
```bash
composer install
```4. Install JavaScript dependencies by running:
```bash
npm install
```5. Compile the assets by running:
```bash
npm run dev
```
For production, use `npm run prod` to minify and optimize the assets.6. Copy the `.env.example` file to a new file named `.env`.
7. Generate an application key by running:
```bash
php artisan key:generate
```8. Configure your database credentials in the `.env` file.
9. Run the database migrations and seeders by executing:
```bash
php artisan migrate --seed
```10. Start the local development server by running:
```bash
php artisan serve
```
The application will be accessible at [http://localhost:8000](http://localhost:8000).### Conclusion
This Laravel blog project exemplifies the robust and elegant features Laravel offers for building modern web applications. By exploring this code, developers can gain insights into Laravel's authentication, Eloquent ORM, Blade templating, testing, and routing features, and understand how to run and build a Laravel application effectively.