At this year’s CakeFest I gave a lighting talk titled “Projects Are Better When Maintained”. Essentially, it was a complaint to be a better maintainer of the open source stuff that you put out. It went over really well and I got some good feedback from it.
One of the key goals of CakePHP 3.0 as discussed recently was making CakePHP 3.0 more decoupled. CakePHP 3.0 has achieved that goal very nicely. Take a look at the CakePHP organization’s repos on GitHub and you will find a long list of decoupled collections of classes that are all part of the overall CakePHP framework that can be used completely independently of CakePHP itself.
Perhaps you are interested in some of CakePHP’s utility classes, like the Security utility, which are a great resource for hashing and encrypting basic data (not passwords) that you want some amount of reasonable security applied to it. Or perhaps you are interested in CakePHP’s Validation system which provides for validating arbitrary arrays of data. The most complex and most interesting part of CakePHP 3 by far is even available for use independent of the rest of the CakePHP core, the ORM layer.
How about an example to help clarify how to use these different pieces in smaller projects. Let’s build a simple webpage that allows us to submit a contact form request and validate it using the CakePHP Validation Library.
I’m doing this in a new `index.php` file in a new directory. First we need to get the Validation Library in our directory.
$ composer require cakephp/validation
That creates a new `composer.json` and loads the CakePHP Validation package. Next in our `index.php` file we need to load the Composer autoloader and the CakePHP Validation Class.
namespace LoadsysTestValidation; require dirname(__FILE__) . "/vendor/autoload.php"; use CakeValidationValidator;
Now at this point we can create a new instance of the Validator class and validate arbitrary arrays of data, like what we would get from `$_POST`.
$validator = new Validator(); $validator ->requirePresence('name') ->notEmpty('name', 'Name is required to be submitted.'); $errors = $validator->errors($_POST);
I worked out a complete example of this and posted it on GitHub as a sample if you need more details or insight into using the CakePHP packages.
The overall CakePHP framework may not be the right choice for everyone in every case. With the recent decoupling of the framework in the 3.0 branch, CakePHP can be more easily used for those times when you want to pick either the very best packages for your problem or you only need a limited subset of features from CakePHP for your web application.
This was previously posted on the Loadsys blog.
I gave this presentation last week at the Las Vegas PHP Meetup, covering some of the new features in CakePHP 3.0. It was a fairly short talk focused mostly on showing off code and some examples of what Cake 3.0 is looking like along with trying to answer some of the questions that I commonly hear inside of this group regarding CakePHP vs. every other framework. The sample project that I built is on Github.
As I give these presentations and watch other people give theirs, I am trying to reflect on them and figure out what works and what doesn’t. One thing that worked for the most part was not trying to write any code during the presentation, instead my idea was to flip through tags in the git repo between hey I did x and look what x did. This wasn’t actually a bad solution but not great. It had the flaw that because I had some changes along the way getting the repo actually working correctly, ignoring
tmp folders, etc, when I tried going to a tag and back I would up having to delete changes and basically reset the repo in the process. So partial credit there I think.
Think of this is a continuation of the topic from November (that one a PHP Classes 101), this one focused on the site http://www.phptherightway.com/ and other tools to help developers build PHP apps the “Right Way”. I also mentioned both The League of Extraordinary Packages as well as PHP-FIG.
I presented at this week’s Las Vegas PHP meetup on PHP Classes and Object Oriented Programming. I did a quick run through of both the basics of OOP and how PHP classes and objects work. If you’ve done PHP OOP for any length of time most everything will be commonplace. Though I did add a bit about SOLID and we had a good discussion on the visibility of properties and methods that was useful for even an experienced user.
Each time I present the feedback says it goes better each time. I’m coming down hard against trying to either present code (outside of slides) or actually live code during a presentation. At least today, in the future after I’ve done this dozens of times I might change it up.
The basis of the talk was getting over the inertia in writing tests in either a pre-existing application or just getting started writing unit tests in general. It went over very well with a good question and answer session afterwards. While I didn’t spend as much time prepping for this talk, I was comfortable enough with the material (and helped there was no code involved) that it was a solid presentation.
The short summary of the talk is for every new method/bug-fix/feature written, write a test for something else at the same time, and start with the stuff that is easier to test.
I’ve been going through a few different pieces of software for writing and displaying my presentations and this is the first time I’ve been really happy with the tool-chain. I used Deckset, which is a Markdown based presentation system with some great looking styles.
Humorous aside, my spelling is atrocious and even though I had to type out “inertia” dozens of times I misspelled it every time and even just now writing this up, I misspelled it every time.
Since moving to Las Vegas, I’ve joined the PHP Users Group. Overall it’s been a great experience meeting people in the community and hearing about more PHP stuff. Since I’ve been there I’ve given a few talks and figured I should list them here.
First up, a talk that was an introduction to CakePHP. Probably my best talk out of the three listed. It was informative, with lots of questions and I knew the material really well (one would hope considering it is my day job).
Next was a talk on Ember.js, this one didn’t turn out so well. I under prepared for it, and it showed. It also didn’t help that I mostly based my talk on a co-worker’s slides. Overall this was novice hour for me. Moral of the story – don’t give talks unless you know the information and don’t try to base a talk using someone else’s work.
Last presentation was one on PHPUnit, which went ok. I knew the material better than the Ember stuff but there were a few weak areas. Overall I think it went pretty well but it could have gone better.
Some random thoughts on public speaking
Public speaking (of a sort) is something that I used to do much more often, it’s been good to stretch that part of my brain over the past few months and get a handle on delivering talks that deal with technical information for a generally technical audience. It is definitely something I want to do more of in the future and to get better at.
Not everyone may want to do this type of thing, but if you are interested in it, I would urge you to give it a shot. It is easier than what you think. I would suggest pick a topic you are very familiar with and can answer questions on the fly about. Feel free if you get a question that you can’t answer to say so, rather than present imprecise information.
So for the tenth anniversary, the Zen Garden is open for business once more. I’ve thrown the codebase on Github, given the dusty copy a refresh, started the conversion of the site to HTML5, and brought all of the existing designs kicking and screaming into the modern age. The work isn’t done yet, but it’s a darn sight closer to what how we would build it these days. If you see an area that needs help, consider sending a patch.
Hello CSS Zen Garden, it’s been awhile.
You want X lines of text. Anything after that, gracefully cut off. That’s “line clamping” and it is a perfectly legit desire. When you can count on text being a certain number of lines, you can create stronger and more reliable grids from the elements that contain that text, as well as achieve some symmetric aesthetic harmony.
There are a couple of ways to get it done, none of them spectacular.
If you are doing Web Design/Development as a full-time and aren’t reading CSS-Tricks, you really should be. Awesome little tricks like this one..
We reported this issue to the Google Vulnerability Rewards Program (VRP). After much heckling from my former colleagues at Google, they quickly pulled this system offline. We also applaud Google for creating a program like the VRP and giving us the chance to share our story with a wider audience. At the time of this blog post, this exact issue affects tens of thousands of devices on the Internet and thousands of different organizations. Thank you Google for helping us raise awareness on this issue! I asked that any proceeds from the VRP be donated to the Wounded Warrior Project, but apparently this issue doesn’t qualify for VRP rewards.
If you have a corporate campus or a modern building of any sort… you’re likely running similar systems someplace on your network. We’ve already discovered over twenty five thousand of these systems facing the Internet… one down, twenty four thousand, nine hundred, ninety nine to go 🙂
If Google can fall victim to an ICS attack, anyone can.
Hacking systems that control a building infrastructure.