PHPackages                             viandwi24/laravel-extension - 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. viandwi24/laravel-extension

ActiveLibrary

viandwi24/laravel-extension
===========================

Plugin, Extension and Module System For Laravel

771PHP

Since Jul 1Pushed 5y ago1 watchersCompare

[ Source](https://github.com/viandwi24/laravel-extension)[ Packagist](https://packagist.org/packages/viandwi24/laravel-extension)[ RSS](/packages/viandwi24-laravel-extension/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

Laravel Extension
=================

[](#laravel-extension)

Plugin, Extension and Module System For Laravel. Inspirate from Wordpress Plugins.

[![screenshot preview](https://raw.githubusercontent.com/viandwi24/laravel-extension/master/resources/screenshot.png)](https://raw.githubusercontent.com/viandwi24/laravel-extension/master/resources/screenshot.png)

Table of contents
=================

[](#table-of-contents)

- [Installing](#installing)
- [Extension Management Page](#extension-management-page)
- [Extension Folder Structure](#extension-folder-structure)
- [Create New Extension](#create-new-extension)
    - [with Artisan Command](#with-artisan-command)
    - [Manual](#manual)
- [Hook](#hook)
    - [Action](#action)
    - [Filter](#filter)
- [Menu Builder](#menu-builder)
- [Unit Test](#unit-test)
- [Examples](#examples)
    - [Making Dynamic css and javascript in html blade](#Making-Dynamic-css-and-javascript-in-html-blade)
- [License](#license)

Installing
----------

[](#installing)

Install from composer :

```
composer require viandwi24/laravel-extension

```

We make this package with Auto Discovery, but you can add manual :

```
# service provider :
Viandwi24\LaravelExtension\LaravelExtensionServiceProvider::class

# aliases
"Extension" => Viandwi24\LaravelExtension\Facades\Extension::class,
"Hook" => Viandwi24\LaravelExtension\Facades\Hook::class

```

Publish Config :

```
php artisan vendor:publish --provider="Viandwi24\LaravelExtension\LaravelExtensionServiceProvider"

```

Added Namespace To Your Composer : (edit your laravel `composer.json`)

```
"autoload": {
    "psr-4": {
        "App\\": "app/",
        "Extension\\": "app/Extension/",
    },
},

```

And then, you can generate composer autoload :

```
composer dump-autoload

```

For first time after installing, you must run this command for generate extension folder in `app\Extension` :

```
php artisan extension:init

```

Extension Management Page
-------------------------

[](#extension-management-page)

For a simple Extension management page, added this route to your rourtes `routes/web.php` :

```
use Viandwi24\LaravelExtension\Facades\Extension;

Extension::routes();

```

Save, and then access in your browser `http://mylaravelproject.test/extension` or 'localhost:8000/extension`, and finaly, you see this page : [![screenshot extension management page](https://raw.githubusercontent.com/viandwi24/laravel-extension/master/resources/screenshot1.png)](https://raw.githubusercontent.com/viandwi24/laravel-extension/master/resources/screenshot1.png)

Extension Folder Structure
--------------------------

[](#extension-folder-structure)

By Default, Extension path in `app/Extension`, you can create Extension in this folder.

```
. app
├── Console
├── Exceptions
├── Extension
│   ├── ExampleExtension
│   │   └── extension.json
│   │   └── ServiceProvider.php
│   ├── MyExtension
│   │   ├── extension.json
│   │   └── MyExtensionServiceProvider.php
│   └── extension.json
├── Http
├── Providers
├── User.php

```

### Artisan Console Command Support

[](#artisan-console-command-support)

Make new extension easy :

```
php artisan extension:new ExampleExtension

```

Update list installed extension :

```
php artisan extension:update-list

```

Get list installed extension :

```
php artisan extension:list

```

Enable a extension : (plugin must be added in list first)

```
php artisan extension:enable ExamplePlugin

```

Disable a extension :

```
php artisan extension:disable ExamplePlugin

```

Inspect a Extension

```
php artisan extension:inspect ExamplePlugin

```

Get Hook list (all)

```
php artisan hook:list

```

Get Hook list specific type (action or filter)

```
# only action :
php artisan hook:list --action

# only filter :
php artisan hook:list --filter

```

Create New Extension
--------------------

[](#create-new-extension)

### with Artisan Command

[](#with-artisan-command)

you can create new extension with this command :

```
php artisan extension:new ExampleTes

```

after success, you can refresh extension list with :

```
php artisan extension:update-list

```

and you can check if updating list success :

```
php artisan extension:list

```

for enable your extension, use :

```
php artisan extension:enable ExampleTes

```

### Manual

[](#manual)

| note : this use indonesian language, you can translate this.

Lokasi extension harus ada pada folder utama extension, secara default ada pada `app\Extension`. berikut panduan singkat cara pembuatan extension :

- membuat folder utama extension, misal `app\Extension\MyPlugin`
- buat file config untuk plugin anda di `app\Extension\MyPlugin\extension.json`, isi dengan :

```
{
    "name": "My Example Plugin",
    "description": "describe your extension.",
    "version": "1.0.0",
    "provider": "MyPluginServiceProvider",
    "author": {
        "name": "viandwi24",
        "site": "https://github.com/viandwi24"
    }
}

```

- Buat service provider untuk extension anda, di folder working extension tadi, sebagai contoh `app\Extension\MyPlugin\MyPluginServiceProvider.php` isinya :

```
