The Http Status Code Is Invalid:

I am in the way to move from Yii1.X to Yii2

I have created Controller,Model and View for a table.

I can see the data in grid view and controller actions are working fine

but when I try create a new entry for the model, it is throwing the below error

on the backend it is actually creating the entry.

Below is the error details in browser:

Invalid Parameter – yii\base\InvalidParamException

The HTTP status code is invalid:

 1. in /Users/XXXX/Sites/yii-advanced/vendor/yiisoft/yii2/yii/web/Response.php at line 254


    public function setStatusCode($value, $text = null)


        $this->_statusCode = (int)$value;

        if ($this->getIsInvalid()) {

            throw new InvalidParamException("The HTTP status code is invalid: $value");


        if ($text === null) {

            $this->statusText = isset(self::$httpStatuses[$this->_statusCode]) ? self::$httpStatuses[$this->_statusCode] : '';

        } else {

            $this->statusText = $text;

2. in /Users/XXXX/Sites/yii-advanced/vendor/yiisoft/yii2/yii/web/Response.php – yii\web\Response::setStatusCode() 

Thanks in advance.

How does your action look like?

Below is the action created by Yii2-gii tool

	public function actionCreate()


		$model = new State;

		if ($model->load($_POST) && $model->save()) {

			return $this->redirect(['view', 'id' => $model->state_id]);

		} else {

			return $this->render('create', [

				'model' => $model,




and the "view" action?..


View action is

	public function actionView($id)


		return $this->render('view', [

			'model' => $this->findModel($id),



That’s strange.

Seems like passed to setStatusCode() $value is string or empty.

Possible bug.

I think you should debug Response.php to see what is coming from outside.

The simplest way is to insert

echo 'Value = ’ . $value; exit; right before $this->_statusCode = (int)$value;

and see what’s the actual value of $value.

But first of all, do ‘composer update’ to make sure you got the latest.

Didn’t do a lot of background checking, but might be related to a recently fixed bug:

Many Thanks.

I have opened an issue at


You are right.

It is fixed a day ago.

I have updated my composer and tested now.