I am new to the Yii Framework and I am trying to get my site up and running. I am running a WAMP server. When I enter the path into my web browser, (in this case 127.0.0.1/advanced/frontend/views/site/index.php), I get the following error:
Fatal error: Using $this when not in object context in C:\wamp\www\advanced\frontend\views\site\index.php on line 5
I have not changed any of the code. I will include the code at the end of this post. Is there a bug in Yii or something?
From what I have researched, I need to go into my .htaccess file and make some adjustments to that file but I am not sure.
I don’t know how to does this. Would anyone know where to go to read up on this information or would anyone be willing to guide me through editing this document?
P.S. I didn’t know you had to install my index.php file so I am going to paste the code in here:
<?php
/* @var $this yii\web\View */
$this->title = ‘My Yii Application’;
?>
<div class="site-index">
<div class="jumbotron">
<h1>Congratulations!</h1>
<p class="lead">You have successfully created your Yii-powered application.</p>
<p><a class="btn btn-lg btn-success" href="http://www.yiiframework.com">Get started with Yii</a></p>
</div>
<div class="body-content">
<div class="row">
<div class="col-lg-4">
<h2>Heading</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et
dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip
ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
fugiat nulla pariatur.</p>
<p><a class="btn btn-default" href="http://www.yiiframework.com/doc/">Yii Documentation &raquo;</a></p>
</div>
<div class="col-lg-4">
<h2>Heading</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et
dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip
ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
fugiat nulla pariatur.</p>
<p><a class="btn btn-default" href="http://www.yiiframework.com/forum/">Yii Forum &raquo;</a></p>
</div>
<div class="col-lg-4">
<h2>Heading</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et
dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip
ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
fugiat nulla pariatur.</p>
<p><a class="btn btn-default" href="http://www.yiiframework.com/extensions/">Yii Extensions &raquo;</a></p>
</div>
</div>
</div>
Alright, I install the basic application of Yii. I’m still getting the same error(HTTP 500 internal error).
I tried the ‘yii serve’ command in the ‘web’ directory and I got the following error:
PHP Warning: require(/var/www/html/basic/vendor/autoload.php): failed to open stream: No such file or directory in /var/www/html/basic/yii on line 14
PHP Fatal error: require(): Failed opening required ‘/var/www/html/basic/vendor /autoload.php’ (include_path=’.:/usr/share/php’) in /var/www/html/basic/yii on line 14