SmartSchema

GitHub: https://github.com/appoly/smart-schema

At Appoly, most of our web applications are developed in the Laravel PHP framework, which also provides an API which many mobile applications interface with. As we work with a lot of clients, facilitating rapid development and improving our efficiency was important.

This formed the basis of our SmartSchema package. SmartSchema saves a huge amount of repetitive developer time by combining the database migration, form views in blade, and data validation in Models, all into one place.

The SmartSchema package is open source, and many of our web team have contributed to it. It is available on our Github.


How it works

When used in a migration, SmartSchema replaces Laravel’s standard Schema for a database migration. In here, in addition to filling in the usual SQL fields (the data type, nullable, etc.), SmartSchema allows the developer to also fill in a range of other properties for each field.

Firstly we have powerful options which allow us to auto-generate forms on the front-end. This way, SmartSchema creates the blade based on a selected form input type (e.g. text, textarea, datetime, checkbox) and a variety of other options; e.g. adding append and prepend or even help text to inputs. The generated forms will have proper validation feedback built in.

Validation rules can also be added to fields in the smart migrations. We can then set whether a field is fillable – no need for protected $fillable = ['really', 'long', 'array', 'of', 'fields', 'here'] in our projects, as a single use SmartField; line in the model is all we need.

In blade files, the HTML can then be rendered from a single line. This completely automates both create and edit forms in Laravel, generated from a single blade file. Meanwhile a single line in the respective controller handles form validation. It’s still possible to render each input individually, should the need to further customise the look of forms arise.

Using in your project

Like many Laravel packages, SmartSchema is pulled straight from the composer. Just run composer require appoly/smart-schema in the terminal to use it in your project.

SmartSchema is best used in new projects rather than existing ones, as it to use it in an existing project would require a migration for every database table that you wish to use it on. However, it will make the creation of new projects extremely straight forward.

What's next?

We’re constantly updating SmartSchema to add features as needed for our own projects.

Is SmartSchema missing any features that you think would make development even faster? Add an issue on Github and we’ll get to it!