seems like a lot of trouble to save a few kilobytes
Are you sure you have optimised all your images? These will have a far greater impact.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I would like to dispatch a job to compress published CSS once the CSS file has been uploaded to Digital Ocean Spaces and then replace uncompressed file by compressed file and update path in database.
So the controller I have something like:
// Copy latest version of the published.stylesheet
\Storage::disk('do')->put($cssSource, file_get_contents(public_path('css/published.css')), 'public');
// activate job and send css source connected to project along
\App\Jobs\CompressCSS::dispatch($cssSource);
Still new to Laravel and Jobs so I wonder, do I need to set the $cssSource in the constructor? So I can use the CSS path to get the not compressed file from the CDN and then gzencode it? How do I do that?
\Storage::disk('do')->get($cssSource, file_get_contents(public_path('css/published.css')), 'public');
$gzippedContent = gzencode($cssSource); // gzip compress the content
in the handler is still looking for $cssSource and $projectPath so I am not sure if dispatch is sending this along to the job..
When I use
public function handle()
{
$projectPath = 'assets/' . $this->project->subdomain_url;
$cssSource = $projectPath . '/css/site.css';
\Storage::disk('do')->get($cssSource, file_get_contents(public_path('css/published.css')), 'public');
$gzippedContent = gzencode($cssSource); // gzip compress the content
}
It does not complain with \App\Jobs\CompressCSS::dispatch($this->project->subdomain_url); for the dispatch.
I guess my question is..
Can I send along the existing cssSource path in dispatch so I can use it in the job?
If so, should I use it as a variable in the constructor, which is not being used at all now?
Please or to participate in this conversation.