Code Monkey home page Code Monkey logo

config's Introduction

Config

Build Status Latest Stable Version Total Downloads Latest Unstable Version License


Easy Configuration Management Library

If you are writing a WordPress theme or a PHP application, most likely you will have some configuration values. The conventional approach involves creating a file with a bunch of variables and constants, then including every file in your script, which may not be the most intuitive way. Inspired by Laravel's elegant configuration handling, I developed Config to provide a similar experience for PHP projects, especially in the context of WordPress themes.


Installation

to install config in your project you just need to run this command

$ composer require azi/config

Up & Running

after installing config you will need to create a directory named config in root of your project where your composer.json lives in this directory you can store your configuration files. i.e database.php or site.php lets say you want to store your database configuration values here. you will have to follow the following steps.

  • create a file called database.php
  • return your configuration values form that file like
  return [
     'mysql' => [
       'host' => '127.0.0.1',
       'username' => 'root',
       'password' => 'secrete'
     ]
   ];
  • access the values from anywhere in your application like
   // will return 127.0.0.1
$host = Azi\Config::get('database.mysql.host');

// OR
$db = Azi\Config::get('database.mysql');
$host = $db->get('host');
$username = $db->get('username');
$password = $db->get('password');

with this package you will also get a little helper function to access values you can also write the above code like this

  // will return 127.0.0.1
  $host = config('database.mysql.host');

Contributers

config's People

Contributors

azeemhassni avatar nhlm avatar

Stargazers

Baran Saeed avatar Junaid Qadir avatar Matthias Kaschubowski avatar  avatar Nam Nguyen avatar

Watchers

James Cloos avatar  avatar

Forkers

golpha

config's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.