dimanche 15 décembre 2019

Laravel - how to use the correct library without conditions?

I have a series of custom libraries that do vastly different things in my application. Which library gets loaded and executed depends on the class name stored in my database, which needs to match the class name written in the PHP file.

PSEUDO CODE:

$class_name = SELECT `class_name` from `some_table` WHERE `some condition is true`
$my_obj = new $class_name;

This is probably OK, but will be a pain should I ever need to add new libraries as it means I need to make a new entry in my database. Is there a better way?

Aucun commentaire:

Enregistrer un commentaire