public static function prepareLogFiles(array $paths) { $fs = new \Symfony\Component\Filesystem\Filesystem(); foreach ($paths as $path) { $fs->remove($path); $fs->touch($paths); $fs->chmod($path, 0777); } }
/** * Check if required folders are writable. * * @return array */ public function checkFolders() { $checked = array(); $problem = false; $fs = App::make('Illuminate\\Filesystem\\Filesystem'); $this->files = App::make('Symfony\\Component\\Filesystem\\Filesystem'); $this->assetPath = public_path('assets'); //push all the directories in storage folder to dirs //array so we check if they are writable as well foreach ($fs->directories(storage_path()) as $sdir) { $this->dirs[] = $sdir; } foreach ($this->dirs as $dir) { if (str_contains($dir, 'imdb')) { $path = public_path($dir); } else { $path = str_contains($dir, 'storage') ? $dir : $this->assetPath . $dir; } //if direcotry is not writable attempt to chmod it now if (!is_writable($path)) { try { $this->files->chmod($path, 0777, 00, true); } catch (Exception $e) { } } $writable = is_writable($path); $checked[] = array('path' => $path, 'writable' => $writable); if (!$problem) { $problem = $writable ? false : true; } } //make a notice if there was a problem or not with folders if //there wasn't a problem with extensions already if (!array_key_exists('problem', $this->compatResults) || !$this->compatResults['problem']) { $this->compatResults['problem'] = $problem; } return $checked; }
/** * Recursiveley create a directory path. * * @param string $path The path we wish to generate. * @param string $mode The (UNIX) mode we wish to create the files with. * @param boolean $absolute Allow absolute paths (default=false) (optional). * * @deprecated since 1.3.0 * @see http://php.net/mkdir * * @return boolean TRUE on success, FALSE on failure. */ public static function mkdirs($path, $mode = 0777, $absolute = false) { if (is_dir($path)) { return true; } $path = DataUtil::formatForOS($path, $absolute); // mkdir does not set chmod properly mkdir($path, $mode, true); $fs = new \Symfony\Component\Filesystem\Filesystem(); $fs->chmod($path, $mode, 00, true); }