dirname() public static method

Extract the parent directory from a file path.
public static dirname ( string $path ) : string
$path string
return string
Example #1
0
 public function index($rule, $file)
 {
     $config = config('imagine.rules.' . $rule, false);
     if (!$config) {
         throw new \Exception(sprintf('Imagine rule "%s" not exists', $rule));
     }
     $route = public_path(substr(route('cache.imagine', func_get_args(), false), 1));
     if (\File::exists($route)) {
         return \Image::make(public_path($route))->response();
     }
     if (!\File::exists($dir = \File::dirname($route))) {
         \File::makeDirectory($dir, 0777, true);
     }
     $image = \Image::make(public_path($file));
     $imagine = new ImagineProcess($image);
     $imagine->call($config);
     return $image->save($route)->response();
 }
Example #2
0
 /**
  * $file_pathが属するパッケージのパスを返す
  * @param $file_path ファイルパス
  * @return string
  */
 public static function module_root_path($file_path)
 {
     $package = File::dirname($file_path);
     while ($package !== null) {
         $package_class = File::basename($package);
         if ($package_class === null) {
             break;
         }
         if (ctype_upper($package_class[0]) && is_file($package . '/' . $package_class . '.php')) {
             return $package;
         }
         $package = File::dirname($package);
     }
     $file = new File($file_path);
     return substr($file->fullname(), 0, strlen($file->ext()) * -1);
 }