I've been writing a lot about Voyager CMS, and that is no coincidence, I've been doing quite a few jobs based on this project. I does make a lot of my basic work a breeze and keeps me from doing a lot of repetitive tasks.
Recently, in a project I was working on, a small PWA for a client, I kept bumping into a situation you all will probably fins all too common. My client kept changing her mind about images and texts that were supposed to be static.
Round about the third time, I got fed up and started creating "settings" for these common items. If you are not sure what settings are, head over here to the academy and watch the settings video. You gotta love this, but it comes with some gotchas.
Another issue I faced every now and then was with creating tables directly on the server with the database administration panel. What seems like a great idea, slowly turns into a nightmare situation. The panel does not create migrations for the tables, and you end up having to either reverse engineer the database or dump the SQL file to get what you need in version control. It works great for a rapid prototyping scenario, but fails for production ready code.
So how do we go about fixing this?
With regards to databases... it's kind of a no brainer. Just use regular migrations to keep your database up to date. Straight out of the box Laravel migrations work just fine. They are kept in you VCS and you will have little or no trouble with regards to how this all works. Need to create a new developer instance... just clone the repository, run the migrations and you'll be developing in no time.
When we talk about settings, things get a bit murkier. Settings are stored in the database. That raised the question as to how one would keep these, in theory, development oriented elements, in version control?
iSeed is a composer package I now have in all of my Voyager installs... It, in a nutshell, creates seeder files from your database.
You can read the full documentation for it here, but I'll give you my twenty cents worth of explanation.
I'll use bash here just because I presume you are running these things on your dev server/machine rather than on the production server (where I would probably - if I really had to - create a job that did this kind of thing for me triggered by some page in the admin area)
You've gone and created a good dozen of settings, grouped into lot's of tabs.
All looks good and now you need to send this to the staging server or upload things to production.
php artisan iseed settings --force
From the root of your project will create/replace your current SettingsTableSeeder file with the seed of your settings table.
Presto! You now have all your settings and base values for them in a versionable file that can be uploaded to you VCS.
I basically user iSeed for anything and everything I need to keep a record of. It works wonders when you, for example, have a staging server that is ready to go live and you need to keep base information stored in the database. It sort of creates a "minimum required version" of the site.
Hope this comes in handy to y'all.
Subscribe to Zombiecorp
Get the latest posts delivered right to your inbox