Custom class cannot be found in Laravel 10
P粉933003350
2023-08-15 21:46:13
<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>
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