Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

Commit

Permalink
Merge pull request #18 from devuri/0.9.1
Browse files Browse the repository at this point in the history
0.9.1
  • Loading branch information
devuri authored Apr 27, 2021
2 parents bfcf95d + 605d5b9 commit ec14736
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 8 deletions.
35 changes: 35 additions & 0 deletions sample-wp-config.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,43 @@

// dump( Setup::init(__DIR__)->getEnvironment() ); // Get the current Environment setup.

// Debug must be on and 'development' set as WP_ENVIRONMENT_TYPE in the .env file.
// dump( Setup::init(__DIR__)->configMap() ); // Display a list of constants defined by Setup.

// this will output the following:

// "WP_ENVIRONMENT_TYPE" => "development"
// "WP_DEBUG" => true
// "SAVEQUERIES" => true
// "WP_DEBUG_DISPLAY" => true
// "WP_DISABLE_FATAL_ERROR_HANDLER" => true
// "SCRIPT_DEBUG" => true
// "WP_DEBUG_LOG" => true
// "DB_NAME" => ""
// "DB_USER" => ""
// "DB_PASSWORD" => ""
// "DB_HOST" => "localhost"
// "DB_CHARSET" => "utf8mb4"
// "DB_COLLATE" => ""
// "WP_HOME" => ""
// "WP_SITEURL" => ""
// "UPLOADS" => "wp-content/uploads"
// "WP_MEMORY_LIMIT" => "256M"
// "WP_MAX_MEMORY_LIMIT" => "256M"
// "CONCATENATE_SCRIPTS" => true
// "FORCE_SSL_ADMIN" => true
// "FORCE_SSL_LOGIN" => true
// "AUTOSAVE_INTERVAL" => 180
// "WP_POST_REVISIONS" => 10
// "AUTH_KEY" => ""
// "SECURE_AUTH_KEY" => ""
// "LOGGED_IN_KEY" => ""
// "NONCE_KEY" => ""
// "AUTH_SALT" => ""
// "SECURE_AUTH_SALT" => ""
// "LOGGED_IN_SALT" => ""
// "NONCE_SALT" => ""
// "DEVELOPERADMIN" => null

// after setup we can define other constant in the normal way or using env function
// or simply use "Setup::get( 'UPLOAD_DIR' )"
Expand Down
12 changes: 5 additions & 7 deletions src/ConfigTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ trait ConfigTrait {
*/
protected static function const(string $key){

$constant = [];
$constant['environment'] = 'development';
$constant['debug'] = true;
$constant['db_host'] = 'localhost';
Expand Down Expand Up @@ -69,21 +68,20 @@ public function apply(): void {
/**
* Display a list of constants defined by Setup.
*
* Debug must be on and 'development' set in the .env file.
* Debug must be on and 'development' set as WP_ENVIRONMENT_TYPE in the .env file.
*
* @return bool|array list of constants defined.
*/
public function configMap(){

$configClass = 'Config';

if ( ! defined('WP_DEBUG') ) return false;

if ( false === WP_DEBUG ) {
return false;
}
if ( false === WP_DEBUG ) return false;

if ( 'development' === env('WP_ENVIRONMENT_TYPE') ) {
$reflectWPConfig = new ReflectionClass(new Config);
return $reflectWPConfig->getStaticPropertyValue('configMap');
return ( new ReflectionClass($configClass) )->getStaticPropertyValue('configMap');
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public static function init( $path ): ConfigInterface {
* @param array|null $environment .
* @param boolean $setup .
*/
public function config($environment = null, $setup = true ) {
public function config( $environment = null, $setup = true ) {

// check required vars.
$this->is_required();
Expand Down

0 comments on commit ec14736

Please sign in to comment.