Orchid CMS - Another CMS on Laravel



    Yes, yes, yes, you read everything correctly, another content management system, you can immediately get a brick and go to the comments to set fire to your torch.

    When I first wrote the first articles about the slim framework, I was advised by many in the comments on the hub to try Laravel, which I thought I did right away. To say that I liked him, to say nothing. But since I worked in the development of sites where speed was required, it was difficult to find a justifiable argument for using it, the only way out was to create an administration package in my spare time, which would allow using my favorite technologies.

    At the beginning


    First of all, I refused the solutions typical for CMS, such as “Design themes”, “Plugins” and “Routing control”. Just let’s be clean right away, not so often a working site needs a change of design, and one way or another, the plug-in must be put by the developer, to whom composer will be nicer. There is no editor of templates or other parameters either, since in reality it conflicted with the version control system.

    Highlights


    First of all, a scheme was developed in which each developer could make some changes to the logic or expand it. I had to think long enough, since there probably doesn’t exist an ideal option, and the approach was chosen where a form that has tabs is created first, each tab is independent, it has no idea that another exists and when the form is submitted, the data comes in turn to each tab. Thus, anyone can create as many of these tabs as you like, adding more and more parameters to the form.

    For example, we have a user form where, by default, two tabs are indicated with general information and access rights, by adding new forms (registered using events) we can expand and add various information, while in the code you will see only a view of the form and action to be done with the resulting model. This approach allows you to expand the already standard tabs and better adapt to the necessary needs.

    An example of a form that can be expanded



    The field of this had to start thinking about how to store data. Thinking about the structure, it was hard not to notice that on most sites (which the company was developing), the data on the structure were very similar, and sometimes translation storage was required. This gave me reason to think about the EAV format, but I found the answer to the question how to store it from the developers from the neighboring department, they used non-relational databases for mobile applications. Transferring this to MySQL and PostgreSQL, the system has already used the JSON type, for storing data, continuing the issue of storage and ease of use, reproduced the wordpress structure, that is, created a record table, and the data was stored in it in JSON format. To carry out the manipulations, a separate field was used to indicate its type. With the help of which, it would be possible to control the record itself.

    That is, the developer, it was necessary to describe the fields that he would like to display for editing and in what form, and the form to build itself. You can also specify validation, or modules, modules - these are the very forms that I talked about above.

    Record Management Example

    namespace DummyNamespace;
    use Orchid\Behaviors\Many;
    class DummyClass extends Many
    {
        /**
         * @var string
         */
        public $name = '';
        /**
         * @var string
         */
        public $slug = '';
        /**
         * @var string
         */
        public $icon = '';
        /**
         * Slug url /news/{name}.
         * @var string
         */
        public $slugFields = '';
        /**
         * Rules Validation.
         * @return array
         */
        public function rules()
        {
            return [];
        }
        /**
         * @return array
         */
        public function fields()
        {
            return [];
        }
        /**
         * Grid View for post type.
         */
        public function grid()
        {
            return [];
        }
        /**
         * @return array
         */
        public function modules()
        {
            return [];
        }
    }
    

    Fields and behaviors are specified separately, which allows you to use only the key, for example, in the record we want a wysing editor, and the value will be a class. This allows you to change the editor from summernote to tinymce or ckeditor in almost one click.

    'types' => [
        App\Core\Behaviors\Many\DemoPost::class,
    ],
    'fields' => [
         'textarea' => Orchid\Fields\TextAreaField::class,
         'input'    => Orchid\Fields\InputField::class,
         'tags'     => Orchid\Fields\TagsField::class,
         'robot'    => Orchid\Fields\RobotField::class,
         'place'    => Orchid\Fields\PlaceField::class,
         'datetime' => Orchid\Fields\DateTimerField::class,
         'checkbox' => Orchid\Fields\CheckBoxField::class,
         'path'     => Orchid\Fields\PathField::class,
         'code'     => Orchid\Fields\CodeField::class,
         'wysiwyg'  => \Orchid\Fields\SummernoteField::class,
     ],

    Using these solutions, the developer can build a CRUD in just a few minutes for many types of data, and changing it by adding new parameters requires only the introduction of new values ​​in their description.

    An example of adding a record form A



    separate point regarding design at the beginning of development, and most likely even now, almost every admin panel used AdminLTE , I do not want to say that it is bad or something else, but to be honest, she’s tired of talking to the designer about the price, I realized that this is not my option. The only way out was the network, then I went to look for beautiful PSD mockups, and found the Dashboard60 UI Kit , having bought it, I started to not accurately or even roughly reproduce the main points (So as not to get over the ears).

    At this stage, the whole“Uniqueness” ends and standard things begin :

    • Role Based Authorization
    • Widgets
    • Tagging
    • Upload files
    • Menu
    • Settings

    Total


    To summarize, the system will be of interest only to those who have already worked with Laravel and want to use it to make “simple sites” with a quick start, this can be seen even at the installation stage , which differs from many other similar applications that make their own a starter package for deployment, Orchid also goes as a package, that is, first you need to deploy the framework itself and after that add the package depending.

    All code is published on github.com .

    Also popular now: