How to fix “An internal server error occurred” in Yii

If you’re running into a near empty screen showing, “An internal server error occurred” in Yii2, check your error logs. It’s a simple fix. My logs showed: An Error occurred while handling another error:\nexception ‘yii\\base\\InvalidConfigException’ with message ‘The directory is not writable by the Web process: /var/www/mp/backend/web/assets’ in /var/www/mp/vendor/yiisoft/yii2/web/AssetManager.php:213 You can resolve it by opening […]

Read More

How to fix “yiisoft/yii2-composer” plugin requires composer-plugin-api 1.0.0

If you’ve been getting the error below: The “yiisoft/yii2-composer” plugin requires composer-plugin-api 1.0.0, this *WILL* break in the future and it should be fixed ASAP (require ^1.0 for example). I’ll try to help you fix it with this blog post. Increasingly, I’m fatiguing of the frequent composer errors that require regular reconfiguration. While you have to […]

Read More

Building Your Startup With PHP: Geolocation and Google Places

Part three of my Building Your Startup series is available now at Tuts+, its focus is HTML5 Geolocation, Google Places and Google Maps. In this part, we’re going to build some of the underlying infrastructure for the concept of Places where people can schedule meetings. We’ll cover the basics of working with Places, building on our […]

Read More

Programming With Yii2: Exploring MVC, Forms and Layouts

As my Programming With Yii2 series continues at Tuts+, part two explores MVC, Forms and Layouts: “This tutorial will cover some of Yii’s more basic concepts related to its implementation of the MVC framework: Models, Views and Controllers. We’ll also explore layouts and customization of navigation menus and Bootstrap elements. For these examples, we’ll imagine we’re building a […]

Read More

How to Display Form Errors (the ErrorSummary)

Let’s say you’re using a validator that doesn’t correspond to a specific field and you want to display it on the form. For example, I’m using the compare validator and wish the error summary to appear on the create form. [php] <?php use yii\helpers\Html; use yii\widgets\ActiveForm; /* @var $this yii\web\View */ /* @var $model frontend\models\Participant */ […]

Read More

How to Use the Yii2 Compare Validation

Here’s an example of how to use the Yii2 compare validator. The rules go in your model e.g. app/models/Participant.php. In this example, I’m ensuring that the participant_id and the invited_by id are not the same. I don’t want someone to be able to invite themselves. [php] public function rules() { return [ [‘participant_id’, ‘compare’,’compareAttribute’=>’invited_by’,’operator’=>’!=’,’message’=>’You cannot invite […]

Read More

How to Count ActiveDataProvider Items

Here’s how to create an ActiveDataProvider in Yii2 and get a count of records: [php] use yii\data\ActiveDataProvider; $participantProvider = new ActiveDataProvider([ ‘query’ => Participant::find()->where([‘meeting_id’=>$id]), ]); echo $participantProvider->getCount(); [/php]

Read More

Web Application Development with Yii 2 and PHP

This is one of the first books written specifically for Yii2: “This book embraces the learn-by-example methodology to show you the most important features of the Yii 2 framework. Throughout the course of this book, you will build a simple real-world application; each chapter will introduce you to a new functionality and show you how […]

Read More

Krajee Yii Extensions

The folks at Krajee have a wide variety of useful Yii2 plugins. Most of them are based on the JQuery UI kit. Visit the Krajee Yii Extensions Homepage  

Read More