gerilla
(Deli Palta)
July 6, 2015, 10:35pm
1
Hi;
i have a advanced yii app. i have common models to use in both frontend and backend. in localhost everything is ok. i created model file in common directory of yii. when i wanna use model i call it with "use commmon\models\Article" and it works ok in every page but site/index. when i try to list all articles in backend site/index i got an error like this:
PHP Fatal Error – yii\base\ErrorException
Class 'app\models\Article' not found
i’ve already added use common\models\Article code to site/index.php but it still says Article model not found. as i said before i get this error only on site/index.php file. i can list all articles in any other view files.
any idea? here is my code
<?php use common\models\article ; ?>
<div class="panel panel-info">
<div class="panel-heading"><h2>Articles</h2></div>
<div class="panel-body">
<?php $articles = Article::find()->all();
echo '<table class="table">';
foreach ($articles as $ur )
{
echo '<tr style="cursor:pointer"><td>'. $ur->id . '</td><td>'. $ur->isim . '</td></tr>';
}
echo '</table>'; ?>
</div>
</div>
nguyendh
(Duynguyen0511)
July 6, 2015, 11:22pm
2
gerilla:
Hi;
i have a advanced yii app. i have common models to use in both frontend and backend. in localhost everything is ok. i created model file in common directory of yii. when i wanna use model i call it with "use commmon\models\Article" and it works ok in every page but site/index. when i try to list all articles in backend site/index i got an error like this:
PHP Fatal Error – yii\base\ErrorException
Class 'app\models\Article' not found
i’ve already added use common\models\Article code to site/index.php but it still says Article model not found. as i said before i get this error only on site/index.php file. i can list all articles in any other view files.
any idea? here is my code
<?php use common\models\article ; ?>
<div class="panel panel-info">
<div class="panel-heading"><h2>Articles</h2></div>
<div class="panel-body">
<?php $articles = Article::find()->all();
echo '<table class="table">';
foreach ($articles as $ur )
{
echo '<tr style="cursor:pointer"><td>'. $ur->id . '</td><td>'. $ur->isim . '</td></tr>';
}
echo '</table>'; ?>
</div>
</div>
My guess is case-sensitive issue.
<?php use common\models\article ; ?>
use <?php use common\models\Article ; ?> instead
gerilla
(Deli Palta)
July 7, 2015, 9:15am
3
it works thanks man. nut i could not understand why it runs under localhost bu fails in server?
Hi!
I guess your localhost is Windows and your Server is Linux? …
If yes:
In Linux the code is case sensitive in Windows not.
Regards
nguyendh
(Duynguyen0511)
July 7, 2015, 7:16pm
5
yup. it’s usually the case