Local server environment - recommendations

Looking for recommendations…

Just wondering which local server environment people are using? I’ve previously used MAMP (as it was recommended in the getting started tutorial back when I first started using SilverStripe) and have used it successfully from SS3.6 to SS4.13. However, MAMP only runs MySQL 5.7…

With MySQL 5.7 reaching EOL and cPanel upgrades on live server requiring MySQL 8.0+ I’m keen to test the switch to 8.0 locally first…

(on that topic, I’m assuming that SS3.6.5 will work on MySQL 8… it’s on the to-do list to upgrade to 5, just not quite there yet… trying to workout whether it’s best to go from SS3.6.5->SS4.13->SS5 or just go direct…)

I’m more in favour of a simple package like MAMP that just does what’s required - phpMyAdmin, MySQL 8, apache… I don’t need every option that’s out there.

Sounds like Laravel Herd would be right up your street. Dead simple to get up and running, and very fast. Doesn’t include MySQL on the Mac, but the free DBngin app makes adding this easy.

1 Like

I strongly recommend using DDEV. It’s a docker-based local development environment manager which deals with a lot of the tedium of keeping things up-to-date for you. You just configure your environment to whatever versions of php, mysql (or mariadb or postgres), etc - and it sets it all up for you.

1 Like

@GuySartorelli Thanks heaps for the tip.

I’ve managed to get DDEV all up and running and transitioned a SS4.13 project which was running in MAMP on MySQL 5.7 to running in DDEV on MySQL 8.0. So far so good… was surprisingly straightforward in the end.

The only caveat I have is that DDEV modified the .env file in the process to:

SS_DATABASE_NAME="db"
SS_DATABASE_CLASS="MySQLDatabase"
SS_DATABASE_USERNAME="db"
SS_DATABASE_PASSWORD="db"
SS_DATABASE_SERVER="db"

I previously had the something like:

SS_DATABASE_NAME="mydbname_SS4_240504"
SS_DATABASE_CLASS="MySQLDatabase"
SS_DATABASE_USERNAME="root"
SS_DATABASE_PASSWORD="root"
SS_DATABASE_SERVER="localhost"

Firstly, does this affect the SS project in anyway?

Secondly, whenever I did a major SS upgrade, I would create a new version of the database, eg. mydbname_SS4_240607, import an sql dump into it (created from exporting the previous db), change the SS_DATABASE_NAME to match in .env and run /dev/build on the new database before beginning any upgrades. This seemed to be a sensible way to ensure I always had a working backup available.

I’d like to be able to do the same in DDEV, but can’t find much documentation on changing the actual default db name to something more meaningful or switching between different databases.

I’ve installed ddev-phpmyadmin, exported and imported into a newly created custom named database mydbname_SS4_240607 (as per Database Management - DDEV Docs). I can change the SS_DATABASE_NAME in .env and when I run /dev/build it builds mydbname_SS4_240607. This all seems to work…

So, is there anything wrong with the above and is there anything I need to watch out for in DDEV by having changed the db name from the default? Will these changes get overwritten on ddev stop/start/restart?

It set the database values to what they need to be for you to access the database that DDEV has set up for you. So the changes to .env in this case were necessary changes.

If you want to use a different database, as you’ve noted you just change the SS_DATABASE_NAME to whatever you’ve named the database after dumping it in.

You may need to set disable_settings_management: true in the .ddev/config.yaml file in your project to make sure it doesn’t swap the database name back to db though. See Managing CMS Settings - DDEV Docs for more information about that setting.

1 Like

@GuySartorelli Thanks that’s very helpful.

I’ve also noticed that every time I run dev/build I’m getting lots of messages like:
changed to mediumtext character set utf8 collate utf8_general_ci (from mediumtext character set utf8mb3 collate utf8mb3_general_ci)

What setting do I need to change in SS or DDEV so that it’s not doing this for every build?

UPDATE: got this working.

I was missing the following from app/_config/mysite.yml

---
Name: myproject-database
---
SilverStripe\ORM\Connect\MySQLDatabase:
  connection_charset: utf8mb4
  connection_collation: utf8mb4_unicode_ci
  charset: utf8mb4
  collation: utf8mb4_unicode_ci

Also needed to add .ddev/mysql/db_collation.cnf (see Extending and Customizing Environments - DDEV Docs)

[mysqld]
collation-server = utf8mb4_unicode_ci
character-set-server = utf8mb4

and had to update all db table and column collations using phpMyAdmin operations.

Hopefully this is helpful to someone in the future!

1 Like