PHPackages                             daniel-cintra/modular-blog - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. daniel-cintra/modular-blog

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

daniel-cintra/modular-blog
==========================

A Blog Module for a Modular Application.

v0.4.6(2mo ago)36903MITPHPCI passing

Since Feb 19Pushed 2mo ago2 watchersCompare

[ Source](https://github.com/ModularThink/modular-blog)[ Packagist](https://packagist.org/packages/daniel-cintra/modular-blog)[ Docs](https://ismodular.com)[ RSS](/packages/daniel-cintra-modular-blog/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (6)Versions (23)Used By (0)

 [ ![Modular Blog](art/modular-blog-github.png)](https://ismodular.com)

[![Vue v3.x](https://camo.githubusercontent.com/ee2133b53ec8a2a831cff097896a87663e62880574173d686faeb4703362840a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5675652e6a732d76332e782d3266343035333f7374796c653d666f722d7468652d6261646765266c6f676f3d7675652e6a73266c6f676f436f6c6f723d333961663738)](https://vuejs.org/)[![Inertia.js v2.x](https://camo.githubusercontent.com/3217a6003f5e6aca9bbcea501cfdc2963dd78acb2f6242161386e8bc12eaa1a6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f496e65727469612e6a732d76322e782d3637363565613f7374796c653d666f722d7468652d6261646765266c6f676f3d696e6572746961266c6f676f436f6c6f723d666666666666)](https://inertiajs.com/)[![Laravel v12.x](https://camo.githubusercontent.com/181f09f8ca6af886f5f41e3df4f16dfdac1b8f6310cf0d4a3c6baffec41bc515/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d7631322e782d4646324432303f7374796c653d666f722d7468652d6261646765266c6f676f3d6c61726176656c)](https://laravel.com)[![Tailwind CSS v4.x](https://camo.githubusercontent.com/5c704e94049e31eca67726a4198dfbbcbfc237e1adc7ebbd1338d2e8a94c344e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5461696c77696e642532304353532d76342e782d3331623566373f7374796c653d666f722d7468652d6261646765266c6f676f3d7461696c77696e642d637373266c6f676f436f6c6f723d666666666666)](https://tailwindcss.com/)[![Tests passing](https://camo.githubusercontent.com/75cd9700550be01374c306fd21973ab75e4080add5f6cbd953ec3aa75ec9b3e7/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f54657374732d70617373696e672d677265656e3f7374796c653d666f722d7468652d6261646765266c6f676f3d676974687562)](https://github.com/daniel-cintra/modular-blog/actions)

Modular's Blog Module
---------------------

[](#modulars-blog-module)

The Modular Blog Module is a comprehensive solution for adding a blog to applications built with the [Modular Project](https://ismodular.com).

The **Blog Module's CMS** (Content Management System) side, has the following features:

- Posts Management
- Categories Management
- Tags Management
- Authors Management

[![Modular Blog Index](art/modular-blog-cms.jpg)](art/modular-blog-cms.jpg)

You can easily create posts using a Fully Featured WYSIWYG Editor, and manage them using a simple and intuitive interface to create, edit, and delete posts, categories, tags, and authors, also allowing you to manage the posts' status and visibility through publication dates.

The **Blog Module Public Views** offers the following features:

- **Archive Selector:** Automatically groups posts by month and year, allowing users to filter posts by specific periods.
- **Tag Selector:** Enables filtering of posts by specific tags. By default, only tags with associated posts are displayed.
- **Search Posts:** Incorporates a simple search feature within the module.

[![Modular Blog Index](art/modular-blog-index.jpg)](art/modular-blog-index.jpg)

Designed as a lightweight yet robust foundation, the Modular Blog Module provides **flexibility for customization and feature expansion** (such as post comments and ratings). This makes it a versatile tool for developers aiming to integrate comprehensive blog functionalities into their applications, catering to a wide array of requirements.

Preparing to install the Modular Blog Module
--------------------------------------------

[](#preparing-to-install-the-modular-blog-module)

Before installing the Modular Blog Module, please ensure the following steps are completed:

1. **Modular Project Installation**: Confirm that the Modular Project is installed and configured in your Laravel application. If this step is incomplete, please consult the [Modular Project's Installation Guide](https://docs.ismodular.com/getting-started.html) for assistance.
2. **Site Files Publication**: With the Modular Project set up, proceed to [Publish Site Files](https://docs.ismodular.com/essentials/site-setup.html) as outlined in the documentation. This step is crucial for successfully integrating the Modular Blog Module.

Now that you have all set, proceed to install the Modular Blog Module.

Installation
------------

[](#installation)

To install the Modular Blog Module, you need to require it using Composer:

```
composer require daniel-cintra/modular-blog
```

Then, initiate the module installation:

```
php artisan modular:blog-install
```

This action publishes essential files and runs migrations, with an option to seed the database with default data.

### Check npm dependencies

[](#check-npm-dependencies)

The Blog Module has a dependency on the [Pinia Store](https://pinia.vuejs.org/) npm package. If you don't have it installed in your project, follow these steps:

1 - On your project root run:

```
npm install -D pinia
```

2 - Open the file `resources/js/app.js` and add the Pinia `import { createPinia } from 'pinia'` and the `.use(createPinia())` blocks.

```
...
import { createPinia } from 'pinia'

createInertiaApp({
    ...
    setup({ el, App, props, plugin }) {
        return createApp({ render: () => h(App, props) })
            .use(createPinia())
            .use(plugin)
            ...
    }
})
```

Final Configuration Steps
-------------------------

[](#final-configuration-steps)

### 1 - BlogServiceProvider

[](#1---blogserviceprovider)

Add the `BlogServiceProvider` to the Providers Array in `/bootstrap/providers.php`

```
return [
    ...
    Modules\Blog\BlogServiceProvider::class,
];
```

### 2 - Backend Menu Items

[](#2---backend-menu-items)

Add the menu items to the `resources/js/Configs/menu.js` items array:

```
export default {
    // Main Navigation - Side Menu
    items: [
        ...
        {
            label: 'Blog',
            permission: 'Blog',
            children: [
                {
                    label: 'Posts',
                    permission: 'Blog: Post - List',
                    icon: 'ri-draft-line',
                    link: route('blogPost.index')
                },
                {
                    label: 'Categories',
                    permission: 'Blog: Category - List',
                    icon: 'ri-folders-line',
                    link: route('blogCategory.index')
                },
                {
                    label: 'Tags',
                    permission: 'Blog: Tag - List',
                    icon: 'ri-price-tag-3-line',
                    link: route('blogTag.index')
                },
                {
                    label: 'Authors',
                    permission: 'Blog: Author - List',
                    icon: 'ri-team-line',
                    link: route('blogAuthor.index')
                }
            ]
        },
        ...
    ]
}
```

### 3 - Frontend

[](#3---frontend)

In `vite.config.js` manually add the `resources-site/js/blog-app.js` entry to the laravel plugin `input` array:

```
plugins: [
    laravel({
        input: [
            ...
            'resources-site/js/blog-app.js'
        ],
        refresh: [
        ]
    }),
    ...
],
```

The Blog Module also includes a **Custom CSS File** for styling the content of the blog posts. This file is located in `resources-site/css/blog.css`. To import this file in your project, add the following line to your main `resources-site/css/site.css` file (after the Tailwind CSS imports):

```
@import './blog.css';
```

With the installation steps completed as outlined, the Blog Module should now be fully operational within your application. This marks the completion of the setup process, enabling you to start using the module's features for managing and publishing blog content.

### Compiling the assets

[](#compiling-the-assets)

To view the changes on your project run:

```
npm run build
```

#### Blog CMS

[](#blog-cms)

To access the Blog Module's CMS (Content Management System), login in to the Modular CMS using the configured path in your `config/modular.php` file in the `login-url` key (for example `/admin`). The Blog Management links will be listed in the sidebar menu.

#### Blog Site View

[](#blog-site-view)

By default, you can access the blog posts controller in the `/blog` route registered by the module.

### Blog Seeders (Optional Step)

[](#blog-seeders-optional-step)

The Blog Module includes two built-in seeders:

1. **BlogSeeder**: This seeder populates your database with `posts`, `authors`, `categories`, and `tags`. It also fetches images online to enrich `posts`, `authors`, and `categories`. Since it retrieves images from the internet, the seeding process may take a few seconds. A progress bar indicator is included within the Seeder, allowing you to monitor the progress of the operation.
2. **BlogAclSeeder**: This seeder creates the Access Control List (ACL) Permissions related to the Blog Module. These permissions can then be associated with the desired `ACL Role` through the application's interface, facilitating the management of user permissions within the blog module.

You have the option to manually run the seeders or include them in the `database/seeders/DatabaseSeeder.php` file for automatic execution. This flexibility allows you to tailor the seeding process to your application's needs, ensuring that the Blog Module is populated with initial data or configured with the necessary ACL permissions as part of your project's overall database seeding strategy.

#### Adding the Seeders to the DatabaseSeeder File

[](#adding-the-seeders-to-the-databaseseeder-file)

To integrate the seeders with your application's seeding process, add them to the `DatabaseSeeder.php` file located in `database/seeders`. Here's how to do it:

1. Import the `BlogSeeder` and `BlogAclSeeder` at the top of your `DatabaseSeeder.php` file.
2. Inside the `run` method of your `DatabaseSeeder`, invoke the seeders by calling their respective `run` methods.

This setup ensures that when you run the database seeding command, both the BlogSeeder and BlogAclSeeder are executed, populating your database with initial blog data and setting up ACL permissions accordingly.

```
