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.
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.
If you plan on releasing a library as open source, please make sure it has
- Clear dependency/installation instructions
- At least one brief documentation guide
- A change log and tags in the repo
- Some information about supported language/runtime/tool versions and project maturity
- A mailing list where users can ask questions and help each other
Doing anything less than this will cause some of your users grief and anger. And likely some wasted time.
Nice suggestions on improving open source projects and making them actually useful to more people than just yourself.
When providing a choice of display options, the computer should almost always respect the user’s stated preference and employ it as the default the next time around. I am amazed at how many sites and applications don’t do this and instead force users to repeat their choices again and again.
In short do pagination but if you offer different options remember what the user selected and use it throughout the site.
Given the incredible progress and innovation we’ve seen in mobile apps over the past few years, I’m not sure we’re any worse off at a macro-economic level, but things have definitely changed and Sparrow is the proverbial canary in the coal mine. The age of selling software to users at a fixed, one-time price is coming to an end. It’s just not sustainable at the absurdly low price points users have come to expect. Sure, independent developers may scrap it out one app at a time, and some may even do quite well and be the exception to the rule, but I don’t think Sparrow would have sold-out if the team — and their investors — believed they could build a substantially profitable company on their own. The gold rush is well and truly over.
via App Cubby Blog – The Sparrow Problem. There is a real problem going to occur with regards to the App Store and desktop/mobile software in general if pure software businesses aren’t able to sustain themselves in the long-term. Apple can get away selling software for cheap thanks to hardware profits, what is the option for software only firms?
You are given two eggs, and access to a 100-storey building. Both eggs are identical. The aim is to find out the highest floor from which an egg will not break when dropped out of a window from that floor. If an egg is dropped and does not break, it is undamaged and can be dropped again. However, once an egg is broken, that’s it for that egg.
If an egg breaks when dropped from floor n, then it would also have broken from any floor above that. If an egg survives a fall, then it will survive any fall shorter than that.
The question is: What strategy should you adopt to minimize the number egg drops it takes to find the solution?. (And what is the worst case for the number of drops it will take?)
There are no tricks, gotchas or other devious ruses. Don’t rat-hole with issues related to terminal velocity, potential energy or wind resistance. This is a math puzzle plain and simple.
Think about the puzzle for a few minutes, and then read on.
via DataGenetics – The Two Egg Problem. Like brain-teasers and computer science algorthims, read on indeed.
But there is no way in hell you can convince me that it’s beneficial for society to not share ideas. Ideas are free. They improve on old things, make them better, and this results in all of society being better. Sharing ideas is how we improve.
via The Word of Notch – On Patents. Notch (the guy who started Minecraft) has a really good piece on why patents are a bad idea. My opinion on patents has slowly changed from thinking that just software and business process patents to getting more convinced that patents in general are a bad idea.