To create a new controller, create a new PHP class inside the controller folder. Name it CookingController.php
. The reason for this? You have been doing this for a while now, so you should continue doing it lest your stomach gets angry. Keep cooking, comrade.
To create a new controller, go to a new PHP class. Use the name CookingController.php
. Do remember the directory <project-root>/app/controllers
. Your controller will look somewhat like the following code:
namespace app\controllers; use app\models\Cooking; use Yii; use yii\web\Controller; class CookingController extends Controller { public function actionIndex(){ $items = new Cooking(); $dishname = 'pizza'; $ingredients = $items->getIngredients(); $toppings = $items->getToppings(); return $this>render('index',array('dishname'=>$dishname, 'ingredients'=>$ingredients,'toppings' => $toppings)); } }