Laravel 5 Elixir Gulp LiveReload

If you are anything like me, you are having trouble getting LiveReload to work in the Elixir overlay for Gulp. Good news is, I’ve finally got it figured out and am here to share. It turns out to be really simple, you just need to create an extension for Elixir. Add this to your gulpfile.js:

Then in your HTML, include this line:

One thing you will notice is in the livereload.changed()  method, I’m passing the word localhost. If you do not pass something there (for whatever reason), you will get an error like this:

It seems to work fine with an asterisk passed there as well. Maybe somebody can comment further what should go there.

PDO Query Nuance: UPDATE WHERE IN Only Updates One Row

I prefer to always use parameterized queries in PDO when possible. Just now, I encountered a situation in which the complications of using them would have not even been worth it. Take a look at this query:

Given that the post_id‘s exist, this will set a deleted flag on all of them right? Ok, let’s try to define that query using PDO and prepared statements…

As it turns out, that will ONLY update the first row. Turns out, the IN clause is a little more complicated than I thought with prepared statements. There is a proposed solution here, but in my case, the data is not user input and can thus sanitize it myself.

Learning Ruby on Rails

completed-rails-for-zombies-redux-cb1011b0ed5f8bb98c97e8e97d7faa3eAs a PHP developer, I’ve always been fascinated with Ruby, specifically the Rails framework. I’ve always felt like I am missing out on something. Recently, I’ve started making a push in my limited spare time to get familiar with the language and idioms of Rails. I’m proud to say, thus far, I have completed the Rails For Zombies course over at Code School. In case you are curious, here is my CodeSchool “Report Card”.

Next steps? I’m going to work on building a rails app from the ground up and learn as I go. As a self-taught developer, I’ve found that spending hours readings the documentation and poring over questions in StackOverflow really helps me to grok the material.

Also, I’ve found a couple other options for learning Ruby.

 

Laravel 4 Session Not Persisting

I pulled out my hair trying to get sessions to persist in Laravel 4 for quite a while. I combed over my code a hundred times and Googled until my eyes bled trying to figure it out. This was my test:

As it turns out, it had to do with my Session configuration in config/session.php. I set my cookie name to something like this:

The lesson here is DO NOT PUT PUNCTUATION IN YOUR COOKIE NAME! Once I removed the period from that cookie name, everything worked fine.

Hope that helps!

OpenCart Dashboard Errors

Have you installed OpenCart and received the following error on the admin dashboard followed by a whole bunch of other issues?

PHP Warning: fopen(/Users/username/Sites/opencart/image/test): failed to open stream: Permission denied in /Users/username/Sites/opencart/admin/controller/common/home.php on line 48

This can be caused by a whole slew of issues. The first thing to try is make sure the folders are writable, typically using the chmod command. From my research in trying to solve my own problem, this is the answer most people give and there are a lot of people it doesn’t help. Here is the solution I found:

1) Find out what user group Apache runs under. For me, it is running in the _www group:

2) Figure out where your main web folder is located. In my example above, I call mine “Sites” on MacOS X but for many it’s called “htdocs” or something else. You should know where your web files go. Open a command line and go to that folder:

3) If you execute an ls -la in the folder, you will most likely see that the group is not the same group as Apache runs under. On Mac, my folders were owned by the “staff” group. We need to change all the files in your web folder to be owned by the same group as Apache executes under:

Of course, replace _www with the group you received in step #1.

Now go back into your OpenCart Dashboard and you shouldn’t have anymore errors.