Using Event file |
I don't understand how to use an Event with a separated file with the function
![]() for example App/Config/Events.php Quote:Events::on('pre_system', ['compress', 'compresstest']); System/Events/compress.php Quote:<?php I always have this error: ErrorException call_user_func() expects parameter 1 to be a valid callback, class 'compress' not found ![]() ![]()
You need to pass a valid callback: https://www.php.net/manual/en/language.t...llable.php
If you're going to use the array format it needs to be [$object, $method] where object is an instance or a class name. For example if you have "app/Libraries/Compress.php" you could use something like: Events::on('pre_system', ['App\Libraries\Compress', 'compresstest']); (03-23-2020, 09:06 AM)MGatner Wrote: You need to pass a valid callback: https://www.php.net/manual/en/language.t...llable.php Thanks! I solved the problem using this Events.php PHP Code: <?php namespace Config; Compress.php PHP Code: <?php namespace App\Eventos; Anyway, thank you very much! |
Welcome Guest, Not a member yet? Register Sign In |