akrabat / slim3-skeleton

Simple Slim Framework 3 skeleton with Twig & Monolog
BSD 3-Clause "New" or "Revised" License
345 stars 99 forks source link

How to make global variables ? #38

Open mridah opened 7 years ago

mridah commented 7 years ago

is there a way I can declare constants somewhere so I can just use them in my controllers ? @akrabat @namaless @needcaffeine @jeremykendall

nunocodex commented 7 years ago

@mridah Isn't the best place where ask support to this. Btw you can define constants where you want, but for me you can define what you want in the container and then you have where you need.

lferro9000 commented 7 years ago

Additionally, if you want to define constants for use on all your controllers, the best way would be to have them all extend a base class that only defines class constants and use them within your controllers. That way, you keep those constants inside your context (aka the controllers).

Just remember that if you start to have too many constants etc, you may be disguising mutations and the like with them, so make sure you don't have overcomplicated switch / if/then/else structures as they are normally a give-away of the need to a better structure in your code.