Error: Class 'atk4\ui\JsToast' not found (only on production server)


I implemented a bunch of toasts to show errors and messages but when I uploaded the files to the production server (I’m currently working on localhost) I get this error everytime I run:

return new \atk4\ui\JsToast(['title' => 'Error', 'message' => 'Message to be shown', 'class' => 'error']);

All the other features and components from Agile UI are working properly, on both local and server.

Do you have any clue on why this is happening only on the server and specifically with the JsToast component? Does it have something to do with JavaScript?

This is the code I use to test:

require_once __DIR__ . '/../../../vendor/autoload.php';
require_once __DIR__ . '/../init.php';

$button = \atk4\ui\Button::addTo($app, 'Show toast')->on('click', function () {
    return new \atk4\ui\JsToast(['title' => 'Error', 'message' => 'Message to be shown', 'class' => 'error']);

Thank you all!

I’m running ATK 1.6.0 and I don’t have a JsToast component in my \atk4\ui\src directory – please verify the file exists. Also ensure the capitalization matches exactly; I have other js*.php files and they all start with lowercase j. On some deployments (PHP version? Operating Systems?) the capitalization matters and on others they don’t.

1 Like

You are right. It was the capitalization I didn’t noticed that!

Thank you so much, you are a hero!

Josep Bernad

Thanks @gcooka for the answer

[…] I have other js*.php files and they all start with lowercase j […]

The problem was using JsToast instead of jsToast.

30/09/2020 UDATE

Looks like on the version 2.2.0, the capitalization changed again and it’s JsToast. Make sure you use the correct capitalization, because usually the servers are case-sensitive and for some reason, my machine (Mac using MAMP) isn’t.