Browse Source

Enforce ext-json into composer.lock

Cleanup the Bootstrap directory/file check
pull/704/merge
Timothée Jaussoin 7 years ago
parent
commit
f44bc2c95d
  1. 1
      composer.json
  2. 5
      composer.lock
  3. 42
      src/Movim/Bootstrap.php

1
composer.json

@ -14,6 +14,7 @@
"ext-dom": "*",
"ext-mbstring": "*",
"ext-imagick": "*",
"ext-json": "*",
"wikimedia/composer-merge-plugin": "^1.0",
"rain/raintpl": "^3.1.0",

5
composer.lock

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"content-hash": "deafca4ea4a03576800cb51827e4754c",
"content-hash": "e3deddef2a9748306d417980b3fcc9f6",
"packages": [
{
"name": "cboden/ratchet",
@ -3055,7 +3055,8 @@
"ext-curl": "*",
"ext-dom": "*",
"ext-mbstring": "*",
"ext-imagick": "*"
"ext-imagick": "*",
"ext-json": "*"
},
"platform-dev": [],
"platform-overrides": {

42
src/Movim/Bootstrap.php

@ -45,45 +45,27 @@ class Bootstrap
private function checkSystem()
{
$listWritableFile = [
LOG_PATH.'/logger.log',
LOG_PATH.'/php.log',
CACHE_PATH.'/test.tmp',
];
$errors = [];
if (!file_exists(CACHE_PATH) && !@mkdir(CACHE_PATH)) {
$errors[] = 'Couldn\'t create directory cache';
}
if (!file_exists(LOG_PATH) && !@mkdir(LOG_PATH)) {
$errors[] = 'Couldn\'t create directory log';
}
if (!file_exists(CONFIG_PATH) && !@mkdir(CONFIG_PATH)) {
$errors[] = 'Couldn\'t create directory config';
throw new \Exception('Couldn’t create cache directory');
}
if (!empty($errors) && !is_writable(DOCUMENT_ROOT)) {
$errors[] = 'We\'re unable to write to folder ' .
DOCUMENT_ROOT . ': check rights';
throw new \Exception('Unable to write to directory ' . DOCUMENT_ROOT);
}
$listWritableFile = [
LOG_PATH . 'logger.log',
LOG_PATH . 'php.log',
CACHE_PATH . 'test.tmp',
];
foreach($listWritableFile as $fileName) {
if (!file_exists($fileName)) {
if (touch($fileName) !== true) {
$errors[] = 'We\'re unable to write to ' .
$fileName . ': check rights';
}
} elseif (is_writable($fileName) !== true) {
$errors[] = 'We\'re unable to write to file ' .
$fileName . ': check rights';
if (!file_exists($fileName)
|| touch($fileName) !== true
|| is_writable($fileName) !== true) {
throw new \Exception('Unable to write to ' . $fileName);
}
}
if (!function_exists('json_decode')) {
$errors[] = 'You need to install php5-json that\'s not seems to be installed';
}
if (count($errors)) {
throw new \Exception(implode("\n<br />",$errors));
}
}
private function setConstants()

Loading…
Cancel
Save