Release Notes
Release Notes
Version 2.2 introduces very exciting features, more flexibility and less work for you out of the box! It also, adds support for the new features that were introduced in Laravel 5.5. Follow is a list of all new features and changes that were introduced.
New Futures
Smart Migrations Engine
Whaaaat?!! Yup that's right, version 2.2 introduce a very powerful feature which keeps track of all your migrations. After migrating, each time, you add/delete a field/index from your resource file, the code-generator will only generate a migration to add/drop and drop/add columns as needed! Keep in mind that you still have to tell the generator that you need to create a new migration using
create:migrationcommand or the--with-migrationoption for thecreate:resourcescommand.Another migration related feature was to organizing your migration files! When uses migrations heavily, finding a specific migration may be overwhelming due to the number of file. This feature, allow you to group all your migrations into sub-folders. Please note that this feature is off by default, to turn it on, set organize_migrations to true.
You're probably thinking "Laravel only detects migrations in the main folder... boooo!" That is correct! However, if you are using Laravel 5.3+, version 2.2 of Laravel-code-generator include five new commands to help you interact with migration from all folders. Check out the "Command Changes" below for more info about the new commands.
Previously Laravel-Code-Generator was limited to belongsTo() type relation. Now, when creating resources from existing database's table, the code-generator is able to create hasOne() and hasMany() relations by scanning the database's constrains and analyzing its existing data.
In the resource-file you can now define any Eloquent relations. Each relation should follow the foreign-relation schema below. Additionally, you can define composite/multi-columns indexes! Each index should follow the index schema listed below.
When using Laravel 5.5, you can pass custom Validation Rule object directly in you resource file and the generator will add it to the validation rules! For more info check out the validation option below
Improved the file uploading process to allow you to delete uploaded file
--indexesand--relationshave been added to the following commandsresource-file:create,resource-file:append, orresource-file:reduceto allow you to interact with the resource-file freely.The options
--fields,--indexesand--relationsfor theresource-file:create,resource-file:append, orresource-file:reducecommands accept complex string to allow you to pass more values to add to the resource-file. For example,--fields="name:colors;html-type:select;options:blue|yellow|green|red|white,name:second_field_name"
More configurations so you can type less and do more!
plural_names_for was added to the configuration file to allow you to set your own plural-form vs singular-form preference when naming controller, form-request, resource-file, language file, table-name and route group. If you like your controllers to be in a plural-form, you can simply change the default behavior from the configuration file!
controller_name_postfix was added to the configuration file to allow you to change the controller's postfix. If you don't like to post fix your controllers with the word Controller, you can set this to an empty string or any other value.
form_request_name_postfix was added to the configuration file to allow you to change the form-request's postfix. If you don't like to post fix your form-request with the word FormRequest, you can set this to an empty string or any other value.
irregular_plurals was added to the configuration file. The code-generator heavily uses Laravel helpers
str_plural()andstr_singular()to generate readable code to make your code spectacular. The problem is the both generate incorrect words for irregular plurals. If you are using a language other than English, you can define a word with each with its plural-form to help the generator keep your code readable.create_move_file_method was added to the configuration file. This option will allow the user to chose not to create moveFile method on every CRUD when file-upload is required. If you set this to false, it is your responsibility make sure that the moveFile method exists in a higher level of your code like
App\Http\Controllers\Controller.New configuration file (i.e
config/code_generator_custom.php) was added to allow you to override the default configuration. This way, you won't lose any of your custom configuration when upgrading which is important! For more info, read the config file.
Cleaner!
In addition to storing fields in the JSON file, indexes and relations can be stored in the same file too! For that reason, the option --fields-file have been renamed to --resource-file in all the commands.
Version 2.2 completely dropped support for raw fields, indexes, and relations as announced in previous documents. Storing resources in JSON file is much better, easier to manage, easier to regenerate resources in the future, shorter/cleaner commands, and much more flexible!
Thanks to the request validation improvement in Laravel 5.5, the controller code is much cleaner.
When the
ConvertEmptyStringsToNullmiddleware is registered, we no longer convert empty string to null manually since the middleware will do just that.The
--without-migrationoption withphp artisan create:resourcescommand has been reversed. It is now--with-migrationand should only be passed when you need a new migration created.For consistency, the --lang-file-name option have been renamed to --language-filename.
The options
--namesin theresource-file:create,resource-file:append, andresource-file:reducehas been renamed to--fields.
Command Changes
The following commands were renamed
The command
create:fields-filehas been renamed toresource-file:from-databaseThe command
fields-file:createhas been renamed toresource-file:createThe command
fields-file:deletehas been renamed toresource-file:deleteThe command
fields-file:appendhas been renamed toresource-file:appendThe command
fields-file:reducehas been renamed toresource-file:reduceThe following commands were added
php artisan migrate-allcommand was added. It allow you to run all of your outstanding migrations from all folders
php artisan migrate:rollback-allcommand was added and it allows you to rolls back the last "batch" of migrations, which may include multiple migration from all folders.
php artisan migrate:reset-allcommand was added to allow you to roll back all of your application's migrations from all folder.
php artisan migrate:refresh-allcommand was added to allow you to invoke themigrate:rollback-allcommand then immediately invokes themigrate:migrate-allcommand.
php artisan migrate:status-allcommand was added to allow you to checks the status of all your migration from all folders.
Bug Free!
All known bugs have been addressed!
Upgrade Guide
- In your composer.json file, update the
crestapps/laravel-code-generatordependency to2.2.*. - Using the command-line, execute the following two commands to upgrade to the latest version of v2.2
composer updatephp artisan vendor:publish --provider="CrestApps\CodeGenerator\CodeGeneratorServiceProvider" --tag=default --force
- If you will be using Laravel-Collective, execute the following commands update the default-collective template.
php artisan vendor:publish --provider="CrestApps\CodeGenerator\CodeGeneratorServiceProvider" --tag=default-collective --force
- Move any custom template "if any" from
resources/codegenerator-templatestoresources/laravel-code-generator/templates. IMPORTANT do not copy the default and default-collective folders. - Move all the file that are located in
resources/codegenerator-filestoresources/laravel-code-generator/sources. Now you should be able to delete the following two folders since they have been relocatedresources/codegenerator-templatesandresources/codegenerator-files. - Finally, there are some changes to the layout stub which are required. To override your existing layout call the following code
php artisan create:layout "My New App". If you are using your own layout, you may want to create a temporary layout and extract the updated css/js code into your own layout/assets. The following command will create a new file called "app_temp.blade.php"php artisan create:layout "My New App" --layout-filename=app_temp