Skip to content

Commit 5b389ce

Browse files
committed
add: new function for make directory
1 parent bcef5c5 commit 5b389ce

File tree

1 file changed

+33
-14
lines changed

1 file changed

+33
-14
lines changed

framework/Helpers.php

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ function js($path)
173173

174174
if (!function_exists('app_url')) {
175175
/**
176-
* @function app_url
176+
* @function app_url for get app root url
177177
* @param $path
178178
* @return string
179179
*/
@@ -214,12 +214,13 @@ function errors($key)
214214
}
215215
}
216216

217-
/**
218-
* @function for create or check path is exist
219-
* @param $path
220-
* @return string
221-
*/
217+
222218
if (!function_exists('path')) {
219+
/**
220+
* @function for create or check path is exist
221+
* @param $path
222+
* @return string
223+
*/
223224
function path($path)
224225
{
225226
$path = trim($path, '/');
@@ -234,7 +235,7 @@ function path($path)
234235
}
235236

236237
/**
237-
* @function for base_path
238+
* @function for get Document root or base path
238239
*
239240
* @param string $path
240241
*
@@ -250,14 +251,14 @@ function base_path($path = null)
250251
}
251252
}
252253

253-
/**
254-
* @function for include file
255-
*
256-
* @param string $path
257-
*
258-
* @return void
259-
*/
260254
if (!function_exists('include_file')) {
255+
/**
256+
* @function for include file
257+
*
258+
* @param string $path
259+
*
260+
* @return void
261+
*/
261262
function include_file($path)
262263
{
263264
$path = base_path($path);
@@ -267,6 +268,24 @@ function include_file($path)
267268
throw new Exception("File not found at {$path}");
268269
}
269270
}
271+
272+
if (!function_exists('check_or_make_dir')) {
273+
/**
274+
* if directory not exist then create directory or return directory path
275+
*
276+
* @param string $path
277+
*
278+
* @return string $path
279+
*/
280+
function check_or_make_dir($path)
281+
{
282+
$path = base_path($path);
283+
if (!is_dir($path)) {
284+
mkdir($path, 0777, true);
285+
}
286+
return $path;
287+
}
288+
}
270289
}
271290

272291

0 commit comments

Comments
 (0)