Featured Posts

FuelPHP Command Line Oil with Windows BAT File And... I have been using the Codeigniter PHP MVC framework for awhile now and have started to realize I need some extra features that are not built in by default.  A few weeks ago...

Readmore

PHP Class To Build HTML Forms I have recently pushed a new repository to Github to showcase a PHP class I built.  This class helps make building HTML forms easier.  I originally built this class to help...

Readmore

Codeigniter Library to Read CSV File I recently posted some code to Github that I created for use in Codeigniter. I built a library that can be used to read CSV files, extract the data you need, and return a...

Readmore

Using PHP Curl To Check Apple Site To See If My Extension... A few weeks ago (probably closer to months now) I built a Safari extension.  I also submitted it to Apple to see if it can be listed on their Safari extensions page.  I...

Readmore

Safari Extensions - Puni.co URL Redirection For anyone interested in URL redirection services and Safari Extensions, here is a service offered by TheBizzTech LLC.  We have made a Safari Extension that uses the free puni.co...

Readmore

TheBizzTech Rss

FuelPHP Command Line Oil with Windows BAT File And XAMPP

Posted on : 23-08-2011 | By : TheBizzTech | In : FuelPHP, Model-View-Controller (MVC), PHP, Programming

Tags: , , , , ,

47

I have been using the Codeigniter PHP MVC framework for awhile now and have started to realize I need some extra features that are not built in by default.  A few weeks ago I came across a Twitter post by Phil Sturgeon about a new PHP framework he is involved in called FuelPHP.  I started looking at it and realized it had a lot of the features right out of the box that I have been looking for.  It has things like Migrations, a Command Line tool, and HMVC.

I am not going to get into all of these features as FuelPHP has some decent enough docs to get you started.  What I am going to explain a little bit about is their command line tool called OIL.  For starters, those of you who know Ruby on Rails will be fairly familiar with the idea of using the command line.  There is a command simply called rails, in Ruby on Rails, that allows you to manage much of your app.  With Oil you can do things such as build scaffolding, inspired by Rails, run your own tasks, and build models and controllers.

Oil works perfectly well on *nix type machines, but I have had issues running PHP command line from Windows 7 and XAMPP.  Here are two ways I have been able to run Oil using Windows command line.  There is a way to be able to type just php from the command line by chaining the PATH, but for some reason I am not able to get it to work on my machine at all.  After many times trying I have just gone with the next two approaches.

When you run a PHP command on *unix you generally just have to type php followed by your commands; this however did not work for me on Windows running XAMPP.  The first way to solve this is instead of just typing php you have to type the full path to the php.exe file.  Since I am running XAMPP I would always have to type something like this “xampp\php\php.exe” every time I wanted to run PHP.

The second option is to run a batch file.  In the main directory of the FuelPHP package their is your file called oil.  In this same directory create a file called oil.bat.  In this file you will put the path to your PHP install and some command line helpers.  This text below is what I have in my oil.bat file and it basically looks for a file called oil and takes the arguments you entered and passed them to oil.


@c:\xampp\php\php.exe %~n0 %*

Note: this may be different for you depending on where you have XAMPP installed, and where your php.exe file is located.  Now to run oil you basically just run something like this from the command line.


oil.bat help

If anyone has an easy way to be able to fix my issue with running a simple php command from the command line let me know, otherwise these two options above should work just fine.

PHP Class To Build HTML Forms

Posted on : 29-04-2011 | By : TheBizzTech | In : Github, HTML, PHP, Programming

Tags: , , , , ,

4

I have recently pushed a new repository to Github to showcase a PHP class I built.  This class helps make building HTML forms easier.  I originally built this class to help make PayPal buttons easier to built into PHP scripts.  I have not looked at this script much since the summer of 2010, but hope to dust it off soon.

Here is a simple example of how to use the class that you can download from Github here, https://github.com/thebizztech/htmlform


<?php
/**
* TheBizzTech
*
* This example utilizes the open source htmlform PHP class built to make building HTML forms easier
*
* @author		Jason Michels
* @link		http://thebizztech.com
*/

//To use the htmlform class you first need to include the file
require("htmlform.php");
?>
<html>
<body>
<?php
// Initialize form class
$form = new htmlform();
// Begin the form and pass array of values
$form->begin_form(array("name"=>"myform","action"=>"index.php","method"=>"post","target"=>"thebizztech"));

// To create a new label include the element id in the "for" array value
$form->form_label(array("for"=>"1stid","text"=>"This is a label: "));

// To create an input field pass array with any standard attributes. The class will check to see which ones are set
$form->form_input(array("type"=>"text","id"=>"1stid","class"=>"1stclass","name"=>"1stname","value"=>"this is the value"));

// Another form input example
$form->form_input(array("type"=>"submit","id"=>"submitform","class"=>"submitform","name"=>"submit","value"=>"Submit Form"));

// Example of a form button
$form->form_button(array("type"=>"button","value"=>"Awesome","text"=>"Awesome button"));

// End of form. This will take one parameter allowing you to add html after the form such as a line in the example
$form->end_form("<hr />");
?>
</body>
</html>