The example for using Yii with the third party includes error on the last script
// legacy code
$id = (int)$_GET['id'];
// new code
require 'path/to/yii_init.php';
$post = \app\models\Post::find()->where['id' => $id];
echo Html::encode($post->title);
just fix the line $post = \app\models\Post::find()->where['id' => $id]; to $post = \app\models\Post::find()->where(['id' => $id]);
Thanks! Yii2 Cookbook is in a separate repository - https://github.com/samdark/yii2-cookbook.
Sorry, @arogachev didn't know about the separate repo, will add there next time.
Also you should add the ->all() or ->one() on the end of the statement $post = \app\models\Post::find()->where(['id' => $id]); , because the very next line calls the
echo Html::encode($post->title);
which throws error
Unknown Property – yii\base\UnknownPropertyException
Getting unknown property: yii\db\ActiveQuery::name
@buttflattery Good catch! Updated the PR with this fix. Thanks!