I have a web-server on windows and Linux based server. When I'm launching Laravel 5 project on windows everything works fine, but I have a trouble with Linux (ubuntu) server and the same trouble on my hosting. When I'm trying to load the index page I'm getting an error like this:
Class 'App\Helpers\Substr' not found
It happened because I'm using custom helpers in my blade templates and had been loading it via the "use" operator like this:
<?php
use App\Helpers\Substr;
use App\Helpers\LoaderBtn;
?>
@extends('zaks.public')
@section('content')
@include('zaks.search')
So, what might be a good solution in this situation when the project has been finished?
First, make sure your classes are autoloaded via Composer or so.
Then, you can add your namespaced classes to the 'aliases'
array in config/app.php
, like this:
'aliases' => array(
// other aliases...
'App_Helper_Substr' => 'App\Helpers\Substr',
);
and then use it right in your view the regular way:
App_Helper_Substr->something...
App_Helper_Substr::something();
You can name your aliases whatever you want.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With