Skip to content

Commit

Permalink
Using PHP DIRECTORY_SEPARATOR
Browse files Browse the repository at this point in the history
  • Loading branch information
NeroReflex committed Jun 7, 2017
1 parent 95ad807 commit ab236ee
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 22 deletions.
8 changes: 5 additions & 3 deletions Documentation/docs/cli/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,20 @@ perform.
To bootstrap a new application the command is fixed:

```sh
./vendor/bin/gishiki new application
./vendor/bin/gishiki init
```

This will create a basic and empty application that uses an sqlite3 database,
has a randomly-generated RSA private key, and is ready to be executed.
has a randomly-generated RSA private key, and an empty SQLite3 database.

The application can be executed immediately if ext-pdo_sqlite is installed.


## Controller Creation
To bootstrap a new controller the command requires controller name:

```sh
./vendor/bin/gishiki new controller ControllerName
./vendor/bin/gishiki new-controller ControllerName
```

This will create a basic controller with a small example piece of code.
8 changes: 4 additions & 4 deletions Gishiki/Core/Environment.php
Original file line number Diff line number Diff line change
Expand Up @@ -275,23 +275,23 @@ public function getConfigurationProperty($property)

case 'RESOURCE_DIR':
case 'RESOURCE_DIRECTORY':
return APPLICATION_DIR.'Resources'.DS;
return APPLICATION_DIR.'Resources'.DIRECTORY_SEPARATOR;

case 'MODEL_DIR':
return APPLICATION_DIR.'Models';

case 'VIEW_DIR':
case 'VIEW_DIRECTORY':
return APPLICATION_DIR.'Views'.DS;
return APPLICATION_DIR.'Views'.DIRECTORY_SEPARATOR;

case 'CONTROLLER_DIR':
case 'CONTROLLER_DIRECTORY':
return APPLICATION_DIR.'Controllers'.DS;
return APPLICATION_DIR.'Controllers'.DIRECTORY_SEPARATOR;

case 'KEYS_DIR':
case 'KEYS_DIRECTORY':
case 'ASYMMETRIC_KEYS':
return APPLICATION_DIR.'Keyring'.DS;
return APPLICATION_DIR.'Keyring'.DIRECTORY_SEPARATOR;

case 'APPLICATION_DIR':
case 'APPLICATION_DIRECTORY':
Expand Down
19 changes: 4 additions & 15 deletions Gishiki/Gishiki.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,27 +41,16 @@ public static function initialize()
//remove default execution time
set_time_limit(0);

//get directory separator
if (!defined('DS')) {
//if php has a directory separator.....
if (defined('DIRECTORY_SEPARATOR')) {
define('DS', DIRECTORY_SEPARATOR);
} else {
//this is the universal separator
define('DS', '/');
}
}

//get the root path
$documentRoot = filter_input(INPUT_SERVER, 'DOCUMENT_ROOT');

(strlen($documentRoot) > 0) ?
define('ROOT', filter_input(INPUT_SERVER, 'DOCUMENT_ROOT').DS) :
define('ROOT', getcwd().DS);
define('ROOT', filter_input(INPUT_SERVER, 'DOCUMENT_ROOT').DIRECTORY_SEPARATOR) :
define('ROOT', getcwd().DIRECTORY_SEPARATOR);

//the name of the directory that contains model, view and controller (must be placed in the root)
if (!defined('APPLICATION_DIR')) {
define('APPLICATION_DIR', ROOT.DS);
define('APPLICATION_DIR', ROOT.DIRECTORY_SEPARATOR);
}
}

Expand Down Expand Up @@ -90,7 +79,7 @@ public static function run()
Environment::getCurrentEnvironment()->fulfillRequest();
} elseif (!defined('CLI_TOOLKIT')) {
//show the no application page!
echo file_get_contents(__DIR__.DS.'no_application.html');
echo file_get_contents(__DIR__.DIRECTORY_SEPARATOR.'no_application.html');
}

//the framework execution is complete
Expand Down

0 comments on commit ab236ee

Please sign in to comment.