• php (>= 5.6.0)

Whats system constants?

In every project there is a bunch of "nearly" static constants and texts which doesn't really belong anywhere. It't addresses, phone numbers and some other "static" content.

What to do with this?

The clear solution would be create a service, ... a bunch of services. Each service to solve each problem.

  • MobileAppLinkGenerator (3 methods, iOS, Android, MS Phone)
  • ContactInformationProvider (getPhone, getAddress, ...)

Well its a lot of troubles. And still you have to decide where to store those values.

I have seen it in all the projects of the world: SystemConstants - a god-class or DB table or file with thousands of lines as project grows.

We dont want neither 1000 services nor 1000 of methods in one god-class.

This library tries to bring some light into those dark places.

Main idea is to separate the constants to services by the problem domain, and still have one (or more) storages with all the data, but not necessary separated by problem domain.


Create some PhoneContactsProvider in your project:

class PhoneContactsProvider extends AbstractProvider 
	public function getShopPhoneNumber($shopIdentifier) {
		return $this->find('' . $shopIdentifier);	


And then you just use your service:

$provider = new PhoneContactsProvider($phonesMysqlDriver);

Its up to you where you would store those constants. Only one implemented Driver is ArrayDriver (I use neon config files). But you can easily write your own, with caching and all those shiny things.


composer require achse/system-constants

Something more

  • Drivers are stored with order you have give into the provider. If there is a key collision it takes value from the first driver.
  • Drivers can take data from anywhere: array, database, API (here some cache will be useful).
  • If you wrote some interesting driver and you are willing to share it, PLEASE let me know or submit a pull request.

No release at this moment. Try to create first one.

Is this addon outdated? Did you find an issue? Please report it.

Componette Componette