Skip to content

Commit 529c011

Browse files
authored
Merge pull request #55 from nguyenanhung/develop
Add function: init_basic_codeigniter_storage_directory
2 parents c93ff32 + 77aae98 commit 529c011

File tree

2 files changed

+42
-7
lines changed

2 files changed

+42
-7
lines changed

helpers/file_helper.php

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ function formatSizeUnits($bytes)
120120
return $bytes;
121121
}
122122
}
123-
if ( ! function_exists('generateFileIndex')) {
123+
if (!function_exists('generateFileIndex')) {
124124
/**
125125
* Function generateFileIndex
126126
*
@@ -164,7 +164,7 @@ function generateFileIndex($file_path = '', $file_name = 'index.html')
164164
return false;
165165
}
166166
}
167-
if ( ! function_exists('generateFileHtaccess')) {
167+
if (!function_exists('generateFileHtaccess')) {
168168
/**
169169
* Function generateFileHtaccess
170170
*
@@ -208,7 +208,7 @@ function generateFileHtaccess($file_path = '', $file_name = '.htaccess')
208208
return false;
209209
}
210210
}
211-
if ( ! function_exists('generateFileReadme')) {
211+
if (!function_exists('generateFileReadme')) {
212212
/**
213213
* Function genarateFileReadme
214214
*
@@ -256,7 +256,7 @@ function generateFileReadme($file_path = '', $file_name = 'README.md')
256256
* Function makeNewFolder
257257
*
258258
* @param string $folderPath
259-
* @param bool $gitkeep
259+
* @param bool $gitkeep
260260
*
261261
* @return bool
262262
* @author : 713uk13m <dev@nguyenanhung.com>
@@ -303,7 +303,7 @@ function makeNewFolder($folderPath = '', $gitkeep = false)
303303
* Function new_folder
304304
*
305305
* @param string $folder
306-
* @param bool $gitkeep
306+
* @param bool $gitkeep
307307
*
308308
* @return bool
309309
* @author : 713uk13m <dev@nguyenanhung.com>
@@ -425,3 +425,38 @@ function getAllFileInFolder($path)
425425
}
426426
}
427427
}
428+
if (!function_exists('init_basic_codeigniter_storage_directory')) {
429+
function init_basic_codeigniter_storage_directory($customizes = array())
430+
{
431+
if (is_cli() && (defined('APPPATH') && defined('FCPATH'))) {
432+
echo "Initialize storage directory" . PHP_EOL;
433+
434+
makeNewFolder(APPPATH . 'cache');
435+
makeNewFolder(APPPATH . 'cache/ci_sessions');
436+
makeNewFolder(APPPATH . 'logs');
437+
makeNewFolder(APPPATH . 'logs-data');
438+
439+
makeNewFolder(FCPATH . 'storage');
440+
makeNewFolder(FCPATH . 'storage/cache');
441+
makeNewFolder(FCPATH . 'storage/cache_db');
442+
makeNewFolder(FCPATH . 'storage/cache_page');
443+
makeNewFolder(FCPATH . 'storage/ci_sessions');
444+
makeNewFolder(FCPATH . 'storage/cookies');
445+
makeNewFolder(FCPATH . 'storage/htmlPurity');
446+
makeNewFolder(FCPATH . 'storage/tmp');
447+
makeNewFolder(FCPATH . 'storage/logs');
448+
makeNewFolder(FCPATH . 'storage/logs/Requests');
449+
makeNewFolder(FCPATH . 'storage/logs-vendor');
450+
file_create(FCPATH . 'storage/logs/accessDenied.log');
451+
452+
if (!empty($customizes) && is_array($customizes)) {
453+
foreach ($customizes as $folder) {
454+
makeNewFolder($folder);
455+
}
456+
}
457+
458+
echo "Storage directory initialized successfully" . PHP_EOL;
459+
}
460+
exit();
461+
}
462+
}

src/BaseHelper.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
*/
2020
class BaseHelper
2121
{
22-
const VERSION = '1.6.5';
23-
const LAST_MODIFIED = '2024-09-08';
22+
const VERSION = '1.6.6';
23+
const LAST_MODIFIED = '2024-09-15';
2424
const PROJECT_NAME = 'CodeIgniter - Basic Helper';
2525
const AUTHOR_NAME = 'Hung Nguyen';
2626
const AUTHOR_FULL_NAME = 'Hung Nguyen';

0 commit comments

Comments
 (0)