1

I cloned an existing laravel5 project from github repository. In my root using Mac terminal I ran composer install I got out put of dependency installation and at some point when output reached

> php artisan clear-compiled

I got the following error

Fatal error: Cannot redeclare createDirIfNotExist() (previously declared in /Users/applebook/projects/referral-system/Laravel5/laravel/config/constants.php:14) in /Users/applebook/projects/referral-system/Laravel5/laravel/config/constants.php on line 20

Script php artisan clear-compiled handling the pre-update-cmd event returned with an error

I'm stuck here since past few hours, nothing is working out. any command artisan , php artisan --version composer update is giving me same error.

Can anyone help me get through this ? Also if anybody suggest me a good tutorial setting up existing laravel5 project on mac os x ?

File under config/constants.php have the following code:

//Ariel //define('FILE_PATH', "/Users/ariel_inter/git"); //define('INVOICES_PATH', FILE_PATH . "/invoices"); //define('PROFILE_PATH', FILE_PATH . "/profiles");

//Server define('FILE_PATH', "/var/www/files"); define('INVOICES_PATH', FILE_PATH . "/invoices"); define('PROFILE_PATH', FILE_PATH . "/profiles");

function createDirIfNotExist($pathDir, $octalPermissions) { $result = TRUE; if (!file_exists($pathDir)) { $result = mkdir($pathDir, $octalPermissions, TRUE); } return $result; }

function getContentTypeByExtensionFile($ext) { $result = "";

if($ext === 'pdf') {
    return "application/pdf";
} else if($ext === 'png') {
    return "image/png";
} else if($ext === 'jpg') {
    return "image/jpeg";
} else if($ext === 'jpeg') {
    return "image/jpeg";
}

return $result;

}`

Khu-tech
  • 43
  • 9

1 Answers1

0

From your error , i can suggest, the function createDirIfNotExist has been loaded more then once, here is some suggestions to fix it:

  1. global search function createDirIfNotExist from all you project, if you find other files contains this function , only keep one in your project,
  2. if above didn't solve you problem, you need to debug where this file (which have function createDirIfNotExist) been include, then try fix it to include_once/require_once.
  3. cut function createDirIfNotExist to a helper function,laravel create helper function
Community
  • 1
  • 1
Raymond Cheng
  • 2,425
  • 21
  • 34