independent full stack developer

/ Developer's blog

How to use JSON and Laravel with MySQL

Monday, September 20, 2021

My lead framework is Laravel, and I really like to use it with MongoDB, and I do it for the most of time. But sometimes, especially when you worked with legacy code, I have to use MySQL that doesn't support JSON as datatype, so in this case I should use json_encode() everytime when I need to store Arrays and json_decode() when I need to get it back.

Laravel is a powerfull framework with a lot of small features for web artisans that makes our life easier, I want tell about Eloquent mutators and Array & JSON Casting.

How to use this mutator? It' easy, Laravel will do it automatically. Let's imaging that we have a some class for Event where we store Speakers, and need to store them in MySQL without JSON support.

read more Like the other 1778 people already did