Code Monkey home page Code Monkey logo

voyager-deployment-orchestrator's Introduction

StyleCI

Introduction

Voyager is an awesome admin tool for laravel. It is very easy to create admin tool for CMS using Voyager's awesome feature BREAD.

Voyager has limitation for the deployment (after you finish the work, create bread and need to publish in production. :) )

Voyager Deployment Orchestrator is the package which will listen BREAD Events (Add, Update Delete) and will generate files, so that BREAD data can be easily seeded.

Installation

composer require drudge-rajen/voyager-deployment-orchestrator

Then publish the default config and seeder file.

php artisan vendor:publish --provider="DrudgeRajen\VoyagerDeploymentOrchestrator\VoyagerDeploymentOrchestratorServiceProvider"

Next, open the config/voyager-deployment-orchestrator.php and add the tables name of which BREAD seeders will be generated.

return [
    'tables' => [
        users
    ],
];

After Publishing the VoyagerDeploymentOrchestratorSeeder class file, autoload composer so that laravel knows about new seeders.

composer dump-autoload

Usage

Voyager Fires Events on Insert, Update, and Delete of BREAD. This package listens for those events and creates respective seeder files.

To run the seeder file:

php artisan db:seed --class=VoyagerDeploymentOrchestratorSeeder

Generating seeder files for tables

VDO also provides an artisan command to generate the seed file for table. In order to generate the seeder file for tables,

php artisan vdo:generate table-name1

It also supports the generation for multiple tables.

php artisan vdo:generate table-name1,table-name2,table-name3

VDO seed generator command will keep the generated seed files inside /database/seeds/breads with prefix TableSeeder

Note: VDO seed generator will not add the seeder file in VoyagerDeploymentOrchestratorSeeder.php class automatically, because this class in only used for BREAD seeders not the tables seeder. If you want to run all the vdo generated seeder at once, please add those in DatabaseSeeder.php class.

Contributing

Run phpcs linter to check for any error that may happen during PR.

composer lint

Fix errors reported by CI during Pull request.

composer fix

Future Tasks

  • Writing Tests

voyager-deployment-orchestrator's People

Contributors

ankitpokhrel avatar d-cell avatar drudgerajen avatar modess avatar mrcrayon avatar ntuple avatar samundra avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

voyager-deployment-orchestrator's Issues

Target class [DrudgeRajen\VoyagerDeploymentOrchestrator\ContentManger\FileSystem] does not exist

Hi, i'm getting the following error [DrudgeRajen\VoyagerDeploymentOrchestrator\ContentManger\FileSystem] does not exist.
Using Laravel Framework 6.18.38

It happens every time i do a require composer require drudge-rajen/voyager-deployment-orchestrator, php artisan optimize, composer dump-autoload... and so.

Illuminate\Contracts\Container\BindingResolutionException  : Target class [DrudgeRajen\VoyagerDeploymentOrchestrator\ContentManger\FileSystem] does not exist.

  at /var/www/vhosts/example.com/example.example.com/vendor/laravel/framework/src/Illuminate/Container/Container.php:805
    801| 
    802|         try {
    803|             $reflector = new ReflectionClass($concrete);
    804|         } catch (ReflectionException $e) {
  > 805|             throw new BindingResolutionException("Target class [$concrete] does not exist.", 0, $e);
    806|         }
    807| 
    808|         // If the type is not instantiable, the developer is attempting to resolve
    809|         // an abstract type such as an Interface or Abstract Class and there is

  Exception trace:

  1   ReflectionException::("Class DrudgeRajen\VoyagerDeploymentOrchestrator\ContentManger\FileSystem does not exist")
      /var/www/vhosts/example.com/example.example.com/vendor/laravel/framework/src/Illuminate/Container/Container.php:803

  2   ReflectionClass::__construct("DrudgeRajen\VoyagerDeploymentOrchestrator\ContentManger\FileSystem")
      /var/www/vhosts/example.com/example.example.com/vendor/laravel/framework/src/Illuminate/Container/Container.php:803

  Please use the argument -v to see more details.

Please help,
Thanks!

Exception occur PDOException: SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect datetime value: 'THE DATE' for column 'created_at'

Firstly - Great Tool! It helps a lot.

Secondly - There is some issues with the generated timestamps in the seeders. When
$ CompaniesBreadTypeAdded.php

\DB::table('data_types')->insert([
  ...
  'created_at' => '2020-04-18T18:58:51.000000Z'
]);

is executed generates Exception occur PDOException: SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect datetime value: '2020-04-18T18:44:23.000000Z' for column 'created_at'

temp fix is to just set it to null but be really happy if that gets fixed.

A small suggestion for a good improvement could be using the Voyager's build in DataRow and DataType models rather than the \DB.

Stub Variable 'datatype_slug_statements' rendering in seed files

Encountering an issue where the {{datatype_slug_statements}} stub variable is being rendered in the seed files for sluggable models. Occurs with a clean install of voyager & default config.

Here's the full seeder being generated:

use Illuminate\Database\Seeder;
use TCG\Voyager\Models\DataType;
use TCG\Voyager\Models\Menu;
use TCG\Voyager\Facades\Voyager;
use TCG\Voyager\Models\MenuItem;

class PagesBreadTypeAdded extends Seeder
{
    /**
     * Auto generated seed file
     *
     * @return void
     *
     * @throws Exception
     */
    public function run()
    {
        try {
            \DB::beginTransaction();

            $dataType = DataType::where('name' , 'pages')->first();

            if (is_bread_translatable($dataType)) {
                $dataType->deleteAttributeTranslations($dataType->getTranslatableAttributes());
            }

            if ($dataType) {
                DataType::where('name', 'pages')->delete();
            }

            \DB::table('data_types')->insert([
                'name' => 'pages',
                'slug' => 'pages',
                'display_name_singular' => 'Page',
                'display_name_plural' => 'Pages',
                'icon' => NULL,
                'model_name' => 'App\\Page',
                'policy_name' => NULL,
                'controller' => NULL,
                'description' => NULL,
                'generate_permissions' => 1,
                'server_side' => 0,
                'details' => '{"order_column":null,"order_display_column":null,"order_direction":"asc","default_search_key":null}',
                'created_at' => '2019-02-26 17:56:03',
                'updated_at' => '2019-02-26 18:03:13',
            ]);

            {{datatype_slug_statements}}
            

            Voyager::model('Permission')->generateFor('pages');

            $menu = Menu::where('name', config('voyager.bread.default_menu'))->firstOrFail();

            $menuItem = MenuItem::firstOrNew([
                'menu_id' => $menu->id,
                'title' => 'Pages',
                'url' => '',
                'route' => 'voyager.pages.index',
            ]);

            $order = Voyager::model('MenuItem')->highestOrderMenuItem();

            if (!$menuItem->exists) {
                $menuItem->fill([
                    'target' => '_self',
                    'icon_class' => '',
                    'color' => null,
                    'parent_id' => null,
                    'order' => $order,
                ])->save();
            }
        } catch(Exception $e) {
           throw new Exception('Exception occur ' . $e);

           \DB::rollBack();
        }

        \DB::commit();
    }
}

And here is the VDO config:

return [
    'tables' => [
        'pages',
	    'posts',
	    'users',
	    'roles'
        //tables names for generating bread seeders.
    ],
];

We're also getting a ModelNotFoundException for the voyager vendor Menu model. But i'll post another issue for that.

Order of Menu Item for a bread data type is not seeded correctly

I move the menu_item to some order, then when re-migrate my tables and run this orchestrator package, the order set for the menu_item is always in the last.

I think we need to listen on the event when the menu_item is moved up or down and saved it in the seeder.

Deprecation Notice

Laravel: ^7.0
Composer: 1.10.5
composer dump-autoload displays deprecation warning.
Message:
Deprecation Notice: Class DrudgeRajen\VoyagerDeploymentOrchestrator\ContentManger\FileSystem located in ./vendor/drudge-rajen/voyager-deployment-orchestrator/src/ContentManager/FileSystem.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v2.0. in phar:///usr/local/Cellar/composer/1.10.5/bin/composer/src/Composer/Autoload/ClassMapGenerator.php:201

VoyagerDeploymentOrchestratorSeeder seederpath is wrong

When trying to run php artisan db:seed --class=VoyagerDeploymentOrchestratorSeeder I got an error that it couldn't find the seeder file in /database/breads/seeds. The seeder files are of course in /database/seeds/breads.

I fixed the seeder path in VoyagerDeploymentOrchestratorSeeder and it fixed it. It looks to be wrong in your repository. I am not 100% sure how this worked before, since this setting must have been wrong before.

Support for Laravel 8

Link to upgrade guide: https://laravel.com/docs/8.x/upgrade#seeder-factory-namespaces
During the generation of the seeder files, we need to add the namespaces

Seeders and factories now use namespaced classes. To accommodate for these changes, add a namespace Database/Factories to your factory classes and Database/Seeders to your seeder classes:

Also, the path to store the seeder files should be changed from database/seeds/breads to database/seeders/breads.

The previous database/seeds directory should be renamed to database/seeders.

Installation question

Hi
To install this, do I need Voyager already in my project, or this creates the Voyager package?

Regards
Adrian

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.