About

Hello, I’m Bill Keck, author of Laravel 5.3 For Beginners and Yii 2 For Beginners. I’m dedicating this blog to announcements on my books on PHP and other programming languages. It will also include announcements on any open source tools I create.

In 2014-2015, I wrote my first programming book, Yii 2 For Beginners. Programming in Yii 2 was a great experience for me, and even though I no longer use the framework, I learned a lot. To everyone who has bought a copy of that book, and to everyone who has left a review on GoodReads.com, thank you, I appreciate your support.

Since 2015, I have gravitated towards the Laravel framework, which was adopted at my workplace as our enterprise level framework. Once I learned how to work with Laravel, I quickly fell in love with it, and it became my framework of choice for all my projects.

In 2015, I started a second blog dedicated to Laravel only. My books on Laravel followed after that.

I’m always passionate about programming, I’m constantly pushing myself to lean more and more. I want to continue to grow as a programmer. I want to help others grow too, as others have helped me. And so welcome to the ongoing journey into the world of modern PHP. Now let’s go create something cool…

Advertisements

15 thoughts on “About”

  1. I came across your site when looking at how to implement the typical way to implement the behavior in a model. I have a bug somewhere and I am not sure it is with Yii2 or in my code.

    The anomaly that I am experiencing is that the created_at column and updated_at column are always the same time. Where the created_at column should never be changed once it has been inserted.

    Originally, I had the following…

    public function behaviors()
    {
    return [
    [
    ‘class’ => TimestampBehavior::className(),
    ‘createdAtAttribute’ => ‘created_at’,
    ‘updatedAtAttribute’ => ‘updated_at’,
    ‘value’ => new Expression(‘NOW()’),
    ],
    ];
    }

    I have since changed it to mirror more exactly your example.

    public function behaviors()
    {
    return [
    ‘timestamp’ => [
    ‘class’ => TimestampBehavior::className(),
    ‘attributes’ => [
    ActiveRecord::EVENT_BEFORE_INSERT => [‘created_at’, ‘updated_at’],
    ActiveRecord::EVENT_BEFORE_UPDATE => [‘updated_at’],
    ],
    ‘value’ => new Expression(‘NOW()’),
    ],
    ];
    }

    The result, however is the same. The created_at column is always the same as the updated_at column. They are both updated when I save();

    My rules for my model are the following.

    public function rules()
    {
    return [
    [[‘site_id’, ‘name’], ‘required’],
    [[‘site_id’, ‘status’], ‘integer’],
    [[‘created_at’, ‘updated_at’], ‘safe’],
    [[‘name’], ‘string’, ‘max’ => 255],
    [[‘url’], ‘string’, ‘max’=>255]
    ];
    }

    This is my controller, when saving data from a form….

    $model = Company::find()->where([‘id’ => $id ])->one();

    if( $model->load( Yii::$app->request->post() ) && $model->validate() )
    {

    $model->save();
    return $this->redirect( ‘/index.php?r=company’ );
    } else
    {
    if( $model == null )
    {
    $model = new Company();
    }

    return $this->render( ‘edit’, [‘model’ => $model] );
    }

    The data is saved correctly, except for the time stamps.

    Thank you in advance for your help.

    Sincerely,
    Marcellus Barrus

    1. That is strange behavior, I haven’t seen it do that before. I think it would be best to post this in the Yii 2 forum and see if anyone has experienced anything similar. The only guess I can throw at it is maybe you have some form input or form model validation overriding the behavior, but that is just a guess. If you have created_at and updated_at on your form, you should remove those fields. If that turns out to be the problem, let me know and I will update the tutorial accordingly

      Otherwise, I’ve used the timestamp behavior a number of times and it always works perfectly.

  2. Bill, Your book is by far the best on the new Yii2 framework.It really gave me a whole host of ideas not found in the more “commercial” books out there. I really hope that you’ll sell enough through LeanPub to give you an incentive to keep up the good work.

    One minor suggestion. Since I bought your book on LeanPub, they’ve published two updates. It would be really helpful to know what’s new in each update. Otherwise we have to resort to attempting to compare the old and the new — not fun!

    By the way, I found a ton of “bugs” in your book. All of them seem to have to do with poor typing skills and failure to follow very clear instructions.

    1. Hi Larry, thanks for the positive comments. I’m glad you are enjoying the book. There were some bugs and typos, but those have now been addressed.

      We had a big update release today, Jan 1, 2015. That means, one, most, if not all, of the typos are caught and two, all the conflicts caused by version differences are now accounted for. The book is only 64 days old and yet there were some changes to Gii and some other minor points during that time, so that had to be addressed.

      I personally rebuilt the application from scratch with a fresh build of Yii 2 following the instructions in the book. It is 100% working as described in the current release.

      All of the updates to the book are free for the life of the book, so you can get the latest copy just by going back to http://www.leanpub.com and downloading it for free. There’s no need to compare versions of the book, the newest version is always authoritative and it always comes out with release notes.

      Also, I am in the process of adding bonus material, so keep an eye out for those updates. They should be out by the end of January 2015.

      No matter how many copies I sell, I will do my best to keep the book up to date. My goal is to make Yii 2 accessible to as many people as possible. I’m committed to helping people in the community. And I’m also committed to maintaining a high standard of quality for the book.

      Thanks again for positive comments, they are much appreciated.

  3. is there a live site or VM that is running the built app already? given that this is a web app framework, it would greatly help visualize what you will be teaching us. it would also make source code distribution easier, if I can ask you to reconsider. your’s is the first book that has not come with source code—if only because this makes any bug fixes more central.

    (I do not know about gists. for example, I am looking at the code on page 49. right now, I copy and paste. not ideal. I am thinking about trying to copy-paste the entire book and then writing code to extract fragments. not ideal, either.)

    would you like trivial updates? for example, add a sentence on p32 that what you are doing is to alias yii2build to localhost for easier typing. more importantly, trivial update #2: do you suggest the beta4 version or the current version? I will note many such minor issues as I read the book, simply because I have a fresh eye. do you want posting here? elsewhere?

    I may also end up writing a short review of the book on the yii2 forum if I get through it, depending on the experience (if great or awful). just started reading…

    1. You don’t have to know anything special about gists. Just click the link, and you go to the code hosted on Github, which is ready to copy and paste. It’s not as simple as hosting the project, the code changes as refinements are made in subsequent chapters, so the final application is not the same at the earlier stages. I have no plans to host the application at this point. I don’t know what you are referring to beta4 version? I really appreciate bug reports, they are best reported through email, it’s easier for me to see. I’m fairly certain at this point that there are no code-breaking bugs. If you have an expectation of perfection in the writing, you are bound to be disappointed. Even at a mere 695 pages, the current length of the book, there are bound to be things that could have been more complete or clear. That said, I cover a lot of topics that typical beginner books do not and by the end of the book, you should be well on your way to a production application and a very good understanding of Yii 2. Please keep in mind that while I’m happy to answer a question, fix a typo, etc., I am no longer developing the book, I have moved on to other projects, so I will not be doing any major rewrites, feature enhancements, or demos of the application.

  4. Hi Bill, thank you for your amazing books. They help me many times. But just one question about yii2-for-beginners: I have an error with user’s side. When I sign up as a user, then logout and then try to login again – there is an error (404 not found). And, when I try to create a profile – nothing happens. Perhaps I have missed something, but I’ve checked all my code according the whole book twice and everything seems clear. How do you think, why is it happens and where should I look for the problem?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: