2

i hope you can help me with my problem.

I have a Laravel application and i wanna optimize all my images.

I use a controller for that, but i have a lot of images, and i get execution_maxim_time_exceed.

I think, the best way to do that is to creat an artisan command.

So, i creat my with php artisan make:command Name command:example.

After, I move my code from controller to handle() from artisan command.

I can use Storage:move($oldPath, $newPath), but i can't use Image:make($filePath).

My file storage is "storage/app/images/image.png" and filePath is 'images/image.png'

When i use the controller, the method isFilePath() from Intervention\Image\AbstractDecoder return true, but in artisan command return false.

Method isFilePath() call the function is_file()

    public function isFilePath()
    {
        if (is_string($this->data)) {
            try {
                return is_file($this->data);
            } catch (\Exception $e) {
                return false;
            }
        }

        return false;
    }

Why i get false from the function is_file() with the same path for file in artisan command, and in controller i get true? (for the same path).

Thanks

RedoColor
  • 137
  • 1
  • 3
  • 14

1 Answers1

2

Ok, i found the solution. In the controller is_file('images/image.png') return true, but in the cli, i need to use the full path so, in CLI i use 'storage/app/images/image.png'.

RedoColor
  • 137
  • 1
  • 3
  • 14