Creating a credit card month/year input can be accomplished with a single database field but Symfony is smart enough to create multiple pull downs for each.  It is NOT smart enough to not require the programmer to exclude the “day” value.  So, what do you do?  There are many workarounds, including using some post rendering JQuery nujitsu, but that’s crazy.  Still, you have to include the “d” in the date’s format or you will get an error.

Since the day will be ignored, you have Symfony render the field then hide it with CSS.  Not as graceful as a solution you’d expect.  There are ways to create customized inputs, but something this simple I found this is a good enough solution in most cases.

Here’s how you add the credit card expiration date field to your form builder, which is usually created in the entity’s “form type”.


->add(
'ccExpirationDate',
'date',
array(
'format' =>'MMM-yyyy  d',
'years' => range(date('Y'), date('Y')+12),
'days' => array(1),
'empty_value' => array('year' => 'Select Year', 'month' => 'Select Month', 'day' => false)
)
)

// Example of outputting the form field in the TWIG template

{{  form_widget( form.payment.ccExpirationDate.day, { ‘attr’: { ‘style’: ‘display:none’ } } )  }}

Disclaimer — this was an idea used in a few different sites, not my original solution but I put it here because I am sure I’ll need to find a way to do this again.


From what I’ve gleaned from Symfony 2.5 documentation, repositories are best when they’re associated with a distinct entity and have a narrow use for that entity and its other related entities, these are logical associations even though all repositories are still reusable, even from other bundles.  Services are more global and easier to instantiate, not to mention that any dependencies of service objects can also be defined in the services.yml file so the Entity Manager or some other dependent classes can also be automatically injected as needed.

Also, the Symfony documentation suggests that any actions/queries contained in repositories should only retrieve information (act as a “getter”) and not alter any data, as opposed to classes called from a service where their utility is interchangeable as database level “getters” and “setters”.  That said, if you need objects that are easily called from within the controller where you may need to alter data, the Symfony documentation is a little thin on the “best practices”.  I think it’s so much easier to call on these actions/queries in the same repositories you’ve already instanced.

For more complex form projects in the past, I have preferred putting such “form handler” objects that need to actually alter data inside a “/Handlers” folder within the bundle’s “/Forms” folder in order to mirror the organization of “/Repositories” while differentiating the purposes of each, just to follow the “best practices” recommended by our friends at Sensio Labs.

For example, I create a new class that might be called upon to alter certain child entities, perhaps an entity that is a collection of entities for some complex form, like so:  “/MyBundle/Forms/Handlers/MainFormHandler.php”.  Then, within this “MainFormHandler.php” class, the Entity Manager is instanced and I can then call on different methods for the purpose of inserting and updating database data.  If you are PHP developer with Symfony experience, I would love to hear your take on repositories, services, and the special “Handler” classes I mention above.

– Aaron Belchamber

Senior Web Developer
Celebrating 20 years of evolutionary marketing


Some people are so enamored with these shiny new project management tools that load so nicely on our smart phones that they forget it should be a transparent part of the project and not a task and part of the process of completing the project.  I’m lucky to be at a place where it’s used very wisely to help communicate to upper management while helping our web development team stay on task and have a true picture where we stand in terms of a project’s true status while itemizing all those to-dos which serve as very helpful reminders of the steps that still need to be taken.  Remember, despite how sometimes they’re advertised, these tools don’t actually do the work of the projects for anyone, there’s nothing magical about them.  They do email notifications to those involved in certain projects automatically, so that can does save some time in the long run, however!

Here is a screen shot of a free project management and tracking plug-in called “CollabPress”.

CollabPress Plugin

CollabPress is a great WordPress plug-in that has a lot of potential for small companies and departments who may feel they could use some better organization.  Base Camp is a collaborative tool that teams, departments, or entire companies use to help keep track of projects.  Project outlines with to-do lists combined with calendars.  Think glorified “Task List and Calendar” that usually comes in your email software, like Outlook or Entourage.

If you are looking for something simple and clean like Base Camp, but perhaps you don’t have a budget to sustain the monthly fee, which I believe starts at about $20/month, you should install the CollabPress plug-in on a WordPress site and give it a test drive.  It takes less than a minute to install and CollabPress (gosh I can’t stand all these CamelCase names) allows you to create projects, tasks, and set up to-do lists that can show up on a clickable calendar.  It’s very straightforward, clean and simple for any user to grasp and find their way around in minutes.

CollabPress Plugin Screenshot 2
An almost empty calendar… something you probably won’t ever see at your job.

It can be managed from within the WordPress admin section, or you can use some shortcodes and embed certain parts of your project and tasks in stand alone pages or posts, allow different users different privilege access, and leave notes for others to see that can optionally be emailed automatically when there is an update.

Sounds a lot like 90% of Base Camp to me.  It may not be robust enough for bigger company projects or if you’re just that big of a corporation and you just love to spend money, or worse, you’re a company that thumbs its nose at “open source” —  that’s your problem.  Just keep in mind that CollabPress enables users who are admins of projects to assign actual priorities to tasks, a basic feature missing in Base Camp.  Another issue with Base Camp, CollabPress, and many other project management solutions is that there are no easy ways to link certain tasks dependent on other tasks, so if you happen to be working with an administrator who’s crazy about setting deadline dates for every little task, you’re going to be changing a lot of due dates around the project calendars.

In other words, you’re going to have to micro-manage the to-do due dates, exponentially increasing the team’s perception of how much they may think they’re being micromanaged, even if they really aren’t.  It could have a demoralizing effect on the team, or you may just delegate the need to begrudgingly move all those due dates of to-do’s constantly down the calendar to someone with more time on their hands.  I know, it could be easier to just meet deadlines, but especially in the case of bigger web projects, it’s hard to predict the unknown factors and issues outside of your web development team’s control.  (You never do know what that “clanky” sound is inside the car’s engine without looking under the hood and perhaps taking the valve covers off.)  Tick a plus for Base Camp, though, at least it allows you to click and drag each task to another date right from within the calendar, something missing in CollabPress.  Still, a little JQuery customization could go a long way to fix a few of these shortcomings for CollabPress.  I’m not complaining, just saying… it wouldn’t be hard to code it and allow a user to click and drag dependent tasks all at once.  Future feature alert, perhaps?!

Recommendation

If you need a centralized place to keep the team on task while encouraging collaboration on bigger projects, I’d recommend first installing and looking into the features that come with CollabPress, it may be robust enough to bring your team in on the same timeline.  Still, Base Camp is very clean and straight forward.  Though Base Camp does have a nicer polished interface, CollabPress’s default settings and interface are navigable and a little time invested in the CSS styling it a bit wouldn’t hurt.  That’s the price for using free software!

More on Base Camp

Truth be told, I’ve been using Base Camp now for a few months and on the surface Base Camp is just a little more robust than using the project, task list and calendar built into Microsoft Office’s full version of Outlook.  It does enough to keep tasks itemized but it lacks a lot of intuitive features you’d expect from a paid service, like task dependencies and setting priorities.  A useful feature is that it allows members of the project to comment on the project, but that’s just a thread that exists on any forum platform.

I am aware of plug-ins that you can install or buy to expand your Base Camp account to possibly achieve more useful automation and functionality, but I find it hard to believe that some basic project management features just don’t come with Base Camp out of the box.  As is, it feels so lightweight that it should be free, it doesn’t really do much more than CollabPress.  It’s a basic project outline with to-do lists where you can set due dates and tasks show up on calendars which can be viewed and separated by project.  The same features built right into many email client programs, by the way.

So why not just use your email client’s project management tools?

Which makes you wonder if your team shouldn’t just look into using the same email client linked to a few Google calendars, but though many departments have tried this route, setting rules and declaring their team will use them to stay up on each others’ projects, seldom do they follow through and instill the habits to use the calendars and the other collaborative tools that come installed on their computers.  Either someone won’t connect to the calendar, someone else will refuse to use the same email client, like Microsoft Outlook (“I only use Macs”), they’ll only use the “Express” version, “I only like Droid — does it come as an app?!” and someone else just won’t seem to be able to find the right buttons because the view got hidden.

Also, most email clients like Outlook are bit clunky and can have too many options and visual “noise” that are distracting and hard to follow, it’s hard enough to keep your email organized without it being a full-fledged secretary under some other tabs or buttons.  It starts to look like an Autodesk 3Ds Max interface, my favorite program in the entire universe, but daunting when you first look at it:

Autodesk 3Ds Max interface

 


If you’ve designed your database and set it up, there’s a quick way to initialize your Symfony bundle to start talking to it within a minute! Here is where using a framework to do those mundane coding tasks empowers developers to focus their time and energy creating solutions and less time focusing on creating tools and setting up an environment to create those solutions.  After all, a lot of those tools are used in one form or another for many different projects, aren’t they?

As a developer, imagine if you have to keep writing some version of PHPMyAdmin over and over again, knowing that PHPMyAdmin does a better job.  That’s where using a PHP framework starts to really put muscle in any company’s web development team.  GET THEM ON A FRAMEWORK!  You’ll be happy you did later.

If you don’t have a YML file but have a table on your database, run this command to import YML file from your database. You can filter by a single table name, but be sure to use the camelCase names since this references Symfony’s objects, which are called Entities. This actually makes sense since as a coder you need to easily distinguish your database field names which usually incorporate underscores, from the class properties that also use class methods which use camelCase.

php app/console doctrine:mapping:import YourAppBundle yml –filter="Table"

Based on an YML File this command will create a single entity for you:

php app/console doctrine:generate:entities YourAppBundle:Table –path src/

And if you want to create all entities

php app/console doctrine:mapping:import YourAppBundle yml
php app/console doctrine:generate:entities YourAppBundle

If you are looking to learn more about the Symfony PHP framework, you can gain confidence watching a real pro slug through a few projects and pick up a lot of great, helpful tips along the way while chuckling at the real English he pervasively sprinkles with entertaining British anecdotes and self-outrage.  Chris, you’re really hard on yourself, and you are by no means a NOOB!  🙂

I finally made it over the Symfony hump and must admit that I wish I learned a PHP framework much sooner.  If you’re on the fence, learn one, trust me, it will be well worth your time.  If you’re stubbornly refusing to look into a PHP framework, the era of “cowboy coding” is over, you will be irrelevant in about 3 years unless you adapt.  Perhaps you should consider learning COBOL and specialize in migrating their COBOL code to web-based and bring them into 2003.  At least they’ll be in the same millennium!

http://mossco.co.uk/symfony-2/free-symfony-2-tutorial-videos/

Why use a PHP framework?

If you use jQuery, Prototype or Angular to speed up your Javascript development, PHPMyAdmin or MySQL Workbench to speed up database design and development, you are already using tools and frameworks to support your web development process.  These are tools probably already in your tool kit which help you accelerate development time by freeing you up to focus on writing more effective, better designed, and more intuitive code without worrying about the tools you need to accomplish those tasks.  Often, we need to use the same tools on other projects, and this interchangeability of the tools in frameworks is where you will achieve compounding returns each time you use it.  There’s a familiarity and understanding, a common ground everyone in your development team will start from.

You will find when you delve deeper into these frameworks that they save you a lot of time so the quality of your code and what it can do is better thought out, structured, ready for re-use, and the results will be exponentially better.  Learning a PHP framework is an investment to better collaborative development environments and smoother sailing for any company who depends on a website.

Future proof your web assets

Another big reason to consider moving your web department to a framework is future compatibility.  As your company grows its web assets, you may expand and find yourself in need of another web developer.  The younger developers may only understand and be effective through a framework.  Sure, the more experienced who don’t use frameworks may argue that they have written a few pseudo PHP frameworks in the past, but those libraries and tools they made were custom built.  Without standardization and a common experience and understanding, unlike many developers share with the real frameworks like Symfony, Zend, CakePHP, Laravel, CodeIgnitor, or Yii to name a few, your company will not gain the benefits these PHP frameworks inherently provide.  It’s compounding returns and with the exception of Zend, moving to a PHP framework will cost you only in time, but the trade off for the future will put you in a much stronger position with much stabler websites and code that will be written that will not only last longer, but be much more useful and effective to your company.  That means more profits with compounding returns and less waste, a pretty good combination, don’t you think?