Code Monkey home page Code Monkey logo

laravel-plugins's Introduction

laravel-plugins

Plugin system for Laravel 5.x and Lumen 5.x. Plugins can overwrite and extend each other.

Usage

For Lumen add to bootstrap/app.php: $app->register(\Astutesixface\LaravelPlugins\PluginServiceProvider::class);

For Laravel add to 'providers' array in config/app.php: \Astutesixface\LaravelPlugins\PluginServiceProvider::class,

Create a plugin

Structure

Plugins must be in app/Plugins. Example plugin structure:

  • Test
    • Http
      • Controllers
        • TestController.php
    • views
      • test.blade.php
    • migrations
      • 2018_06_15_000000_create_test_table.php
    • routes.php
    • TestPlugin.php

The TestPlugin class must extend the Astutesixface\LaravelPlugins\Plugin class, containing a unique $name property and a boot() method.

Views

In the boot() method of your plugin call $this->enableViews(). Optional you can pass a relative path to the views directory, default to views. Views automatically have a namespace ("plugin:{name}"), the name is defined by the the main plugin class in a camel case format, with Plugin stripped from the end. For the example above it would be plugin:test. To render a view you can either write the namespace yourself or use the helper method view() in the plugin class. For example view('plugin:test::some.view.name');

Routes

In the boot() method of your plugin call $this->enableRoutes(). Optional you can pass a relative path to the routes file, default to routes.php. You automatically have access to the $app variable. Routes are automatically grouped to your plugin namespace, so you only have to type the controller name without the namespace.

Controllers

Controllers must be in PluginDirectory->Http->Controllers.

Migrations

In the boot() method of your plugin call $this->enableMigrations(). Optional you can pass a relative path to the migrations directory, default to migrations. Keep in mind that migrations must follow the yyyy_mm_dd_tttt_<name>.php naming convention, for example 2014_10_12_000000_create_users_table.php would be a valid migration.

How to extend another plugin

see examples/extend

ToDo

  • Move plugin directory and project namespace to publishable config file

laravel-plugins's People

Contributors

astutesixface avatar senither avatar dweipert-3138720606 avatar texxlan avatar mhanoglu avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.