RSS
 

Reviving the ccPHP Framework

10 Nov

I had kinda given up on my PHP framework (as I’d mentioned in “Simplicity via PHP Frameworks” article). But as I embarked on another little web project and realized that I might benefit from some helpers in case the project grows to become less “little.” I could’ve started with a new micro-framework or I could dust off my languishing ccPhp framework. Since my goal with the framework was to get up and running quickly, I figured I’d recall its use quicker than trying to figure out a new one.

So, I pulled the source from my Github repo. It included a small sample—perfect for quickly getting started. I quickly found out that I had left the source in a non-working state (my attempt to use namespaces). There were other gotchas that I had to refresh my memory about (not to mention refreshing my PHP proficiency). So, it did take longer than I would have liked to get up and running.

Getting away from the framework for a while had another backhanded advantage: brain cells familiar with the framework’s details have died, leading me to a fresh look at the framework. I found that it was not as easy to get to core business logic, as I would have liked. What became obvious to me as I was developing the framework, was no longer obvious. Also, my approach for how to solve the problem was a bit different than what I anticipated when I wrote the framework.

I realized that I needed to better describe and organize its interfaces—a refinement rather than a revamping of the original design. I finally added a brief README.md file to the Github project, put more thought into simplifying the interfaces, and refined the code. This should all help get people (including myself) up and running more quickly.

Crystallizing ccPhp Concepts

As I wrote the readme, I crystallized my original concepts more succinctly. I noted that, at its core, it has a very programmatic approach to building a web page. That is, it assumes PHP code will be used to generate content… PHP and content, mixed. Though that can be circumvented through the use of adjuncts (e.g., the Smarty controller that was originally implemented), the base primitives presume PHP/content mix.

Focusing on usage of the framework, I identified different approaches to its usage.

  • The original approach assumed the creation of a public stub file that directs to an application-specific bootstrap file (e.g., app.php) which links to the framework via ccApp.php. From there, create a class to generate content. To start, that can be contained in one class, extending one of the provided base classes. This is three groups of code, the public code, the app-specific code, and the framework.
  • We can simplify this for some scenarios by allowing the content generation class to be the sole application implementation class. It would link to ccApp.php, but a lot of the content of app.php could have default settings which would be implemented in the ccApp.php framework initialization. This would reduce the minimal groups to two, the public code and the framework, for simple applications.
  • Since the approach is programmatic, it would be nice to have a structure that directly paralleled HTML structure.

The original framework purposefully did not impose rules about the organization of application files. If more assumptions were made, e.g., file/directory organization correlating to URL structure, these simple starts could be built upon as needed.

Most of this can be done with adjuncts to the existing framework, with some thought. You can assume that most of this will be part of its evolution.

Reviving ccPhp

It took longer than I would have liked, to get up and running. The good news is (1) that I “fixed” problems that I’d left the source code and, more importantly, (2) I have refined the framework to better meet my goal of being easy to use. Knowing too much can lead to a less than ideal solution. Microsoft has shown this, too, in their past. ccPhp is alive, again!

 
 

Simplicity via PHP Frameworks

05 Apr

A long time ago, I’d endeavored to create my own lightweight PHP framework, ccPHP. It was a good exercise, but never reached prime time. Around that time I began to notice a lot of others endeavoring to do the same thing (i.e., create simpler, lighter weight PHP frameworks that didn’t take more time to learn than to implement the project). I’ve been away for a while and things have changed.

  1. The continued refinement and simplification of frameworks.
  2. The greater emphasis on frontend apps to do more of the work that used to be done in the middle tier.
  3. The ubiquity of RESTful interfaces, the dividing line between front-ends and servers.

Micro-PHP Frameworks

I doubt that I will ever finish my own framework, now that others are a lot closer to the goals that I was moving towards. And, right now, I simply want to find a lightweight modular frameworks that truly help me get my core work done.  Dragan Gaic did a great survey of the PHP hot frameworks in “Top 12 Best PHP RESTful Micro Frameworks (Pro/Con)“.

A key feature of such frameworks is for them to be modular… to allow me to pick and choose only the components I need, rather than have to install, understand, and run a bunch of functionality that I do not need. It makes it harder for the developer and impacts performance of the results. Model-View-Controler (MVC) is a common software architecture pattern. With the client side being far more capable of managing the “view” part, on its own, the server side can be simpler. Instead of cluttering up the server-side app with trying to display information, it can simply focus on securing data and access and providing data services via RESTful interfaces.

So, what I am looking for are pieces to help me access persistent data and build RESTful interfaces. And something to help keep all the code flow organized. Based on the article, I can look at Silex, Slim, Lumen, or Phalcon for the latter. For database access, I’ve worked with RedBeans before and liked it, so I will probably pick that up again. If one of the frameworks doesn’t help implement and configure a RESTful interface simply, then I may get back into the framework building business again.

Model: RedBeans
View: Frontend client
Controler: one of  Silex, Slim, Lumen, or Phalcon

 

Solving git Problems with Prune

28 Jan

gitThe more I use git, the more I find that it is not as bullet-proof as I have been led to believe. Though, so far, there seems to always be a way out of a problem. Such is the case when I was unable to update a local branch from our

Your configuration specifies to merge with the ref 'my_branch'
from the remote, but no such ref was fetched.

No matter what I did to recreate my local branch, I could not pull from the remote. Google and StackOverflow was of no help—misdirecting to unhelpful information. It turned out that even through I’d fetched the current state of the remote server, my index was still showing a remote branch that did not really exist. Running the following command cleaned that up—and all was well:

$ git remote prune origin
Pruning origin
URL: git@github.….com:….git
 * [pruned] origin/my_branch
$ _

For some reason there was a phantom remote branch that fetch did not update in my local index, properly. Otherwise prune is pretty innocuous, so it might be worth running, every once-in-a-while to make sure that your index is an accurate reflection of the remote.

Enhanced by Zemanta
 
 

git “Getting Started” Tips

21 Jan

git is has become one of the most popular source code control tools on the planet. Even if you’re coming from another source control system, becoming proficient with git can take some time. The best place to start is by running through the git Tutorial. Before that, you might take a look at the GitGuys article to get a quick synopsis of git concepts. Also, though slightly out of date, keeping the following diagram in front of you will help as well. It shows the git command-line commands that “move” file changes from one place to another in the git data-store hierarchy. Read the rest of this entry »

 
 

Activating OS X’s Builtin Apache Web Server and PHP

14 Jan

As I mentioned in my prior post OS X Command-line Dev Tools—Install Shortcut, OS X comes with a variety of built-in tools suited for developers. Unfortunately, Apple has seen fit to hide one of the most important of them: the web server. Despite that, they are easily unlocked if you know how. This applies to Mountain Lion (10.8) and (though I haven’t tried it, yet) Mavericks (10.9). Though you can install separate installations, I don’t like to install anything extra, unless I must. Read the rest of this entry »

 

Command line clipboard in OSX and Cygwin

03 Dec

I use the command line a lot, even though I am on a graphical user-interface like Windows or OSX. And since I’m lazy, I write a lot of scripts to perform repetitive tasks. The downside of command-line is that there is no standard way to interact with GUI features. I stumbled across a command in OSX, recently that allows command line programs to copy/paste between the clipboard that we’re so used to using.

OSX pbpaste and pbcopy

OSX has two commands, pbpaste and pbcopy, Read the rest of this entry »

 

Syncing Github Forks

26 Nov

GitHub_LogoGithub has become the place to manage source code—it’s free, robust, and commonly accessible. Github repositories are owned and access to change them must be enabled by the owner. Still, you can make changes to a Github repository; but a “pull request” must be sent to contributors of the repository and they can accept the change at their discretion. Keeping changes in sync when you don’t have direct change privileges may not be obvious.

One-time Github Changes Read the rest of this entry »

 

PHP Recipe to Show Source-code

19 Nov

PHP programming referenceHere is a simple Web 1.5 (static HTML with a little bit of styling and JavaScript) recipe to allow a viewer of your web page to see the PHP source code of the page with a minimal amount of JavaScript and a little CSS manipulation—good for showing the work you’ve done to others. Or for embedding in your own source, in debug mode, so that teammates can see each others’ work.

See the example code at: http://cachecrew.com/sample_code/highlight_file.php and http://cachecrew.com//sample_code/highlight_file2.php.

The PHP and HTML Read the rest of this entry »

 

OS X Command-line Dev Tools—Install Shortcut

12 Nov

Xcode command-line toolsAmong those around me, in world of tech startups (even in the vicinity of the world of Windows), MacBooks are used almost universally. I can’t explain the discrepancy between what I see around me and the data you usually read; but I do know that as a technical platform, OS X provides an easier path to development tools. These days, the world driven by web-based applications. A majority of those applications run on Linux-based machines. OS X shares with Linux, a common ancestor, Unix. So, a robust array of common commands come with OS X—ssh, ftp, bash, vi, emacs, etc. But more importantly, OS X comes pre-installed with hottest development tools used for web development, today—Ruby, Python, PHP, Apache, memcache, etc. This means a developer can write web applications without even being connected to the Internet!

There are more tools available with the free download of Xcode, Read the rest of this entry »

 

Self-documenting Bash Scripts Using Heredoc

22 Jul

It is surprising how quickly we forget how to use scripts we had written, let alone, what they were for. So it is even more difficult for others to know how and whether to use your script. You can avoid wasting the efforts you put into the problems you solved with your script by simply adding some friendly “help” output.

Here is some basic information you should include:

  • Summary description
  • Form of use—basic syntactic usage
  • Description of usage syntax; i.e., input parameters
  • More detailed information, if necessary. Read the rest of this entry »