search

Home  >  Q&A  >  body text

Custom class cannot be found in Laravel 10

<p>I created a custom class in laravel 10 located at: </p> <pre class="brush:php;toolbar:false;">AppHelpersCompletedOrders</pre> <p>This class contains the following code: </p> <pre class="brush:php;toolbar:false;"><? namespace AppHelpersCompletedOrders; class DeliverOrdersByMail { public static function DeliverOrdersToCustomerMail($OrderID) { return "mail ok ". $OrderID; } }</pre> <p>When I try to call the class in the file: </p> <pre class="brush:php;toolbar:false;">use AppHelpersCompletedOrdersDeliverOrdersByMail; Route::get('test', function(){ DeliverOrdersByMail::DeliverOrdersToCustomerMail("fgzefef"); });</pre> <p>I got a class not found error! </p> <blockquote> <p>Class "AppHelpersCompletedOrdersDeliverOrdersByMail" not found</p> </blockquote> <p>Is there any solution? </p>
P粉933003350P粉933003350524 days ago545

reply all(1)I'll reply

  • P粉996763314

    P粉9967633142023-08-16 09:39:33

    PHP short_open_tag(<?) Deprecated. So you need to use <?php instead of <?

    In PHP 8.0, deprecation notifications are converted to parsing errors:

    In PHP 9.0, support for short_open_tag has been completely removed:

    Reference: https://wiki.php.net/rfc/deprecate_php_short_tags_v2

    reply
    0
  • Cancelreply