PHPackages                             carone/laravel-content - 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. [API Development](/categories/api)
4. /
5. carone/laravel-content

ActiveLibrary[API Development](/categories/api)

carone/laravel-content
======================

A light-weight CMS for Laravel projects

1.1(2mo ago)010MITPHPPHP ^8.2CI passing

Since Dec 31Pushed 2mo agoCompare

[ Source](https://github.com/EmileCar/laravel-content)[ Packagist](https://packagist.org/packages/carone/laravel-content)[ RSS](/packages/carone-laravel-content/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (4)Versions (4)Used By (0)

Laravel Content Manager
=======================

[](#laravel-content-manager)

A lightweight, developer-friendly content management package for Laravel applications. This is **not a full-fledged CMS**, but rather a simple solution for managing editable text and images directly in your views, perfect for quick content updates and typo fixes without deploying new code.

Features
--------

[](#features)

- 🚀 **Simple Integration** - Drop-in Blade components for editable content
- 📝 **Text, Image &amp; File Support** - Manage text content, image paths, and file downloads
- 🎨 **Built-in Visual Editor** - Clean, modern interface for managing all your content
- 🔒 **Authentication Aware** - Only show edit indicators to authenticated users
- ⚡ **Performance Optimized** - Built-in caching support for fast content retrieval
- 🎯 **Customizable** - Extensive configuration options
- 🔧 **Developer-Friendly** - Minimal setup, maximum flexibility

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

[](#installation)

Install the package via Composer:

```
composer require carone/laravel-content
```

### Publish Configuration

[](#publish-configuration)

Publish the configuration file to customize the package settings:

```
php artisan vendor:publish --provider="Carone\Content\CaroneContentServiceProvider" --tag="config"
```

This creates a `config/content.php` file where you can configure routes, middleware, caching, and default values.

### Run Migrations

[](#run-migrations)

Publish and run the migrations to create the `page_contents` table:

```
php artisan vendor:publish --provider="Carone\Content\CaroneContentServiceProvider" --tag="migrations"
php artisan migrate
```

### Publish Views (Optional)

[](#publish-views-optional)

If you need to customize the component views:

```
php artisan vendor:publish --provider="Carone\Content\CaroneContentServiceProvider" --tag="views"
```

Usage
-----

[](#usage)

### Basic Text Content

[](#basic-text-content)

Use the `editable-text` component to create editable paragraphs:

```

```

With custom classes and attributes:

```

```

### Image Content

[](#image-content)

Use the `editable-image` component for editable images:

```

```

With custom attributes:

```

```

### File Downloads

[](#file-downloads)

Use the `editable-file` component for downloadable files:

```

```

With custom link text:

```

```

By default, the component displays the filename as link text. Use the `text` attribute to customize it.

Content Editor
--------------

[](#content-editor)

The package includes a beautiful, built-in visual editor for managing all your content.

### Accessing the Editor

[](#accessing-the-editor)

Navigate to the editor at:

```
https://yoursite.com/admin/content

```

(The prefix is configurable via `CONTENT_ROUTE_PREFIX`)

### Editor Features

[](#editor-features)

- **📋 Page List** - View all pages with accurate content counts in the sidebar
- **✏️ Inline Editing** - Edit content values directly with instant save
- **➕ Add Content** - Add new content with dynamic component code snippets
- **📋 Copy to Clipboard** - Copy component code with one click
- **🗑️ Delete Content** - Remove individual content items
- **🗑️ Delete Pages** - Remove entire pages with all their content
- **🔍 Route Explorer** - Discover and quick-add content for any application route
- **💾 Auto-save** - Changes are saved immediately with visual feedback

### Dynamic Component Snippets

[](#dynamic-component-snippets)

When adding new content, the editor shows you the exact Blade component code to add to your view, updated in real-time based on your inputs:

- Updates automatically as you type the element ID
- Changes when you select a different content type
- One-click copy to clipboard
- Example: ``

### Delete Pages

[](#delete-pages)

Each page view includes a "Delete Page" button that removes the entire page and all its content items. This feature is also available when page loading fails, allowing you to clean up corrupt or invalid page entries.

### Route Explorer

[](#route-explorer)

The editor includes a powerful "Route Explorer" feature that helps you quickly start managing content for any page in your application:

1. Click **"Discover Routes"** at the bottom of the sidebar
2. Browse all your application's web routes
3. Click **"Quick Add"** next to any route to:
    - Add the page to your sidebar
    - Automatically open the "Add Content" modal
    - Start creating content immediately

Pages added via Route Explorer are tracked in the frontend until you save your first content item, making it easy to explore without cluttering your database.

### API Routes

[](#api-routes)

The editor uses the following API endpoints (all under `/api/admin/content` by default):

- `GET /page/{pageId}` - Fetch content for a specific page
- `POST /content` - Create or update content
- `DELETE /content/{id}` - Delete a content item
- `DELETE /page/{pageId}` - Delete an entire page with all content
- `GET /routes` - Get all application routes

These routes automatically include the `api` middleware and can be further protected via your config.

### Editor Access Control

[](#editor-access-control)

By default, the editor is protected by the middleware defined in your config:

```
'middleware' => [
    'web',
    'auth',
],
```

Add additional middleware for fine-grained control:

```
'middleware' => [
    'web',
    'auth',
    'can:manage-content',  // Require specific permission
],
```

### How It Works

[](#how-it-works)

1. **Define Content Areas** - Add ``, ``, or `` components in your views with unique element identifiers
2. **View Your Pages** - Content displays with default values when not yet defined
3. **Edit Content** - Use the visual editor to update content or authenticated users see edit indicators on the frontend
4. **Store in Database** - Content is stored per page and element combination

### Content Retrieval

[](#content-retrieval)

The package provides a `get_content()` helper function that retrieves all content for the current route:

```
$content = get_content();
$value = $content->get('about-me-text');
```

Content is automatically cached based on your configuration settings for optimal performance.

Console Commands
----------------

[](#console-commands)

The package provides convenient Artisan commands for managing content:

### Create Content

[](#create-content)

Interactively create new page content:

```
php artisan content:create
```

With options for automation:

```
php artisan content:create --page=home --element=hero-title --type=text --value="Welcome to our site"
```

Features:

- ✅ Page ID validation (prevents invalid routes like `/`)
- ✅ Duplicate detection with update option
- ✅ Context-aware prompts based on content type
- ✅ Automatic cache clearing
- ✅ Shows component code to add to your view

### List Content

[](#list-content)

Display all page content in a clean table:

```
php artisan content:list
```

Filter by page or type:

```
php artisan content:list --page=home
php artisan content:list --type=image
php artisan content:list --page=about --full  # Show full values
```

Features:

- 📋 Grouped by page when showing all content
- 🎨 Color-coded content types
- ✂️ Automatic value truncation (use `--full` to disable)

### Clear Content

[](#clear-content)

Clear content from the database:

```
# Clear all content (with confirmation)
php artisan content:clear

# Clear specific page
php artisan content:clear --page=home

# Skip confirmation
php artisan content:clear --force
```

Features:

- ⚠️ Confirmation prompts for safety
- 🗑️ Shows what will be deleted before clearing
- 🧹 Automatic cache clearing

Configuration
-------------

[](#configuration)

The `config/content.php` file provides extensive customization options:

### Table Name

[](#table-name)

Customize the database table name:

```
'table_name' => env('CONTENT_TABLE_NAME', 'page_contents'),
```

### Route Configuration

[](#route-configuration)

Configure the admin routes prefix:

```
'route_prefix' => env('CONTENT_ROUTE_PREFIX', 'admin/content'),
```

### Middleware Protection

[](#middleware-protection)

Protect your content management routes with middleware:

```
'middleware' => [
    'web',
    'auth',
    // Add custom middleware like 'can:manage-content'
],
```

### Default Values

[](#default-values)

Set default text, images, and files when content is not yet defined:

```
'defaults' => [
    'text' => env('CONTENT_DEFAULT_TEXT', '-- No content available --'),
    'image' => env('CONTENT_DEFAULT_IMAGE', 'images/placeholder.png'),
    'file' => env('CONTENT_DEFAULT_FILE', 'files/placeholder.pdf'),
],
```

### Caching

[](#caching)

Enable or disable caching and configure cache duration:

```
'cache' => [
    'enabled' => env('CONTENT_CACHE_ENABLED', true),
    'ttl' => env('CONTENT_CACHE_TTL', 3600), // 1 hour
    'key_prefix' => env('CONTENT_CACHE_PREFIX', 'laravel_content_'),
],
```

### Environment Variables

[](#environment-variables)

You can set these in your `.env` file:

```
CONTENT_TABLE_NAME=page_contents
CONTENT_ROUTE_PREFIX=admin/content
CONTENT_DEFAULT_TEXT="Content coming soon..."
CONTENT_DEFAULT_IMAGE=images/default.png
CONTENT_DEFAULT_FILE=files/default.pdf
CONTENT_CACHE_ENABLED=true
CONTENT_CACHE_TTL=7200
```

Database Structure
------------------

[](#database-structure)

The package creates a `page_contents` table with the following structure:

ColumnTypeDescriptionidbigintPrimary keypage\_idstringRoute name or page identifierelement\_idstringUnique element identifiertypeenumContent type ('text', 'image', or 'file')### Page ID Validation

[](#page-id-validation)

Page IDs must follow these rules to ensure valid URLs:

- ✅ **Valid**: `home`, `about`, `contact`, `blog/post-1`, `products/category`
- ❌ **Invalid**: `/` (root route), paths with `//` (double slashes)
- Must start and end with alphanumeric characters
- Can contain: letters, numbers, hyphens (`-`), underscores (`_`), dots (`.`), forward slashes (`/`)

**Note**: The root route `/` cannot be used as a page ID. Use `home` or another identifier instead.

The editor's Route Explorer will automatically:

- Display a warning for routes with invalid page IDs
- Suggest alternatives (e.g., `home` for `/`)
- Disable the "Quick Add" button for invalid routes

API Routes
----------

[](#api-routes-1)

The package registers the following routes (under your configured prefix):

MethodURIDescriptionGET`/pages`List all pages with contentPOST`/pages`Create/update page contentGET`/pages/{page}`Show specific page contentPUT/PATCH`/pages/{page}`Update page contentDELETE`/pages/{page}`Delete page contentUse Cases
---------

[](#use-cases)

Perfect for:

- ✅ Landing pages with editable hero sections
- ✅ About pages with team member bios and photos
- ✅ Contact information that needs occasional updates
- ✅ Feature descriptions and marketing copy
- ✅ Footer content and legal text
- ✅ Downloadable files (PDFs, documents, etc.)
- ✅ Quick typo fixes without redeployment

Not ideal for:

- ❌ Complex content hierarchies
- ❌ Multi-language content (no built-in i18n)
- ❌ Rich text editing with formatting
- ❌ Actual file uploads (only stores paths/URLs)
- ❌ Content versioning and workflows

Requirements
------------

[](#requirements)

- PHP 8.2 or higher
- Laravel 12.0 or higher

Security
--------

[](#security)

The package is designed to work with Laravel's built-in authentication. The editable indicators only show to authenticated users via `auth()->check()`.

**Important**: Ensure you protect your content management routes with appropriate middleware to prevent unauthorized access.

Contributing
------------

[](#contributing)

Contributions are welcome! Please feel free to submit a Pull Request.

License
-------

[](#license)

This package is open-sourced software licensed under the [MIT license](LICENSE).

Author
------

[](#author)

**Caron Emile**
Email:

Support
-------

[](#support)

For issues, questions, or suggestions, please open an issue on GitHub.

---

**Note**: This package provides the foundation for content management but does not include an admin UI for editing content. You'll need to implement your own editor interface or integrate with your existing admin panel.

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance86

Actively maintained with recent releases

Popularity7

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~57 days

Total

2

Last Release

79d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c0f820aee6fd5e896865c14d04a7776ece292213e788023bc07a1ea63e6206c1?d=identicon)[carone](/maintainers/carone)

---

Top Contributors

[![EmileCar](https://avatars.githubusercontent.com/u/114223326?v=4)](https://github.com/EmileCar "EmileCar (17 commits)")

---

Tags

apilaravelcmscontent management

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/carone-laravel-content/health.svg)

```
[![Health](https://phpackages.com/badges/carone-laravel-content/health.svg)](https://phpackages.com/packages/carone-laravel-content)
```

###  Alternatives

[essa/api-tool-kit

set of tools to build an api with laravel

52680.5k](/packages/essa-api-tool-kit)[mollie/laravel-mollie

Mollie API client wrapper for Laravel &amp; Mollie Connect provider for Laravel Socialite

3624.1M28](/packages/mollie-laravel-mollie)[riclep/laravel-storyblok

A Laravel wrapper around the Storyblok API to provide a familiar experience for Laravel devs

6272.7k4](/packages/riclep-laravel-storyblok)[joy/voyager-api

This Laravel/Voyager module adds REST Api with swagger support to Voyager.

204.7k3](/packages/joy-voyager-api)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
