Setting up the Project and Package5:06 with Alena Holligan
Although environment variable are not code specific, we can still benefit from using a package to work with these variable. This video will demonstrate the application we'll be working with and step through the basics of working with the phpdotenv package.
Many developers writing object-oriented applications create one PHP source file per class definition. One of the biggest annoyances is having to write a long list of needed includes at the beginning of each script (one for each class).
Since PHP 5, this is no longer necessary. The spl_autoload_register() function registers any number of autoloaders, enabling for classes and interfaces to be automatically loaded if they are currently not defined. By registering autoloaders, PHP is given a last chance to load the class or interface before it fails with an error.
Composer has accepted the standard put out by the PHP-FIG (Framework Interop Group) of how autoloaders should work in PSR-4: Autoloading
Setting Environment Variables
There are many different ways to set/access environment variables.
- Through code
- On the system*
* try a google search for your particular setup
You need to sign up for Treehouse in order to download course files.Sign up