Ramblings

February 4, 2010

What’s your ‘no framework’ PHP framework? – Stack Overflow

Filed under: dev, frameworks, php — michaelangela @ 7:04 pm

I recently did a project for a film company in New York. Neat group. I did the PSD2HTML/CSS, Flash, jQuery goodness, and other related functionality on the server side. Fun stuff. But it didn’t need a complex backend so it’s just simple PHP. That made me start to ask the same question asked here:

Even with a ton of PHP frameworks out there to choose from, I know many people prefer a minimal, personal set of libraries. What is your method when it comes to ‘rolling your own’ framework for PHP applications, and how does it vary depending on the type/scope of a project?

via What’s your ‘no framework’ PHP framework? – Stack Overflow.

There were a good number of recommendations. I actually really liked using CodeIgniter but at that time there was no user management. I believe it did cleaning of input for you when needed. Most CI solutions were older/not maintained, or had other issues that made it not something I wanted to do again. There was one library that I ended up using, and I’ll have to dig up the name of it. It was an early release at the time and I had to hack it to work with Flash. Hmm, I just saw this… I’ll have to take a look at that. Oh and there is also this… Hmm… going to have to peruse this list a bit more

ANyway, so, a lightweight PHP framework/library that cleans up input (no XSS attacks, etc.) and has easy validation, user management… one user from  the original Stack Overflow question mentioned Flourish:

Flourish is a PHP unframework — a general-purpose, object-oriented library.

It has a modular architecture, meaning it isn’t strictly MVC. It focuses on being securewell documented and easy to use, while solving problems intrinsic to web development.

Why Use Flourish?

You will find Flourish useful if you need to write code that is any of the following:

  • Secure
  • Consistent and easy to understand
  • Needs to model simple or complex databases, especially existing schemas
  • Works with international data
  • Can perform accurate math calculations
  • Easily manipulates images
  • Able to run on different databases (MySQL, PostgreSQL, SQLite, MSSQL, Oracle)
  • Can be used on closed-source projects
  • Needs to run on PHP 5.1.6
  • Needs an architecture other than MVC
  • Plays nicely with other libraries and frameworks

via Flourish — PHP Unframework.

December 7, 2009

Enjoyable PHP tutorials?

Filed under: education, php — michaelangela @ 6:46 am

I haven’t had time to look at this yet but from the comments it seems people really do enjoy this set of tutorials. 🙂 I’ll pass it on to anyone I know that’s just learning but I’ll try to take a look to learn how to breakdown PHP concepts into plain English.

PHP 101: PHP For the Absolute Beginner

This area is intended for everyone new to PHP. It opens with a series of informal, entertaining tutorials written by Vikram Vaswani, founder and CEO of Melonfire. These tutorials build on a previously-published 5-part series which has now been updated and extended to embrace PHP 5, making parts of it suitable for those of you who already have worked with PHP 4 in the past.

If you came here to learn about elementary PHP 4 or basic PHP 5, this is for you. Enjoy!

PHP Design Patterns

Filed under: education, php — michaelangela @ 6:43 am

And examples. Their a Java version at the site as well. Very helpful to get a hands-on grasp of what these concepts are. I have used Factories, Singletons, Facades, Composition, Commands, Mediators, Iterators, Observers, State, and some others BUT I haven’t always known I was doing so or what it was I was actually doing. This kind of reference helps clear those things up.

PHP Design Patterns – FluffyCat.com

November 23, 2009

Flash and Salesforce: HTTP POST using PHP but with no access to cURL

Filed under: cool, php, salesforce, tip — michaelangela @ 11:53 pm

Have a client who needs some Flash to HTTPS webservice functionality. Flash and HTTPS are a difficult pair when not on the same host and all the policy files aren’t in place. The simple solution is a proxy. But this particular client’s webserver doesn’t have cURL. What to do? Making streams with a custom context is really simple. Looks good too. In the end I didn’t use fopen, stream_get_contents, etc. though. I used file_get_contents.

HTTP POST from PHP, without cURL – Evil, as in Dr.

I don’t think we do a very good job of evangelizing some of the nice things that the PHP streams layer does in the PHP manual, or even in general. At least, every time I search for the code snippet that allows you to do an HTTP POST request, I don’t find it in the manual and resort to reading the source. (You can find it if you search for “HTTP wrapper” in the online documentation, but that’s not really what you think you’re searching for when you’re looking).

And there is also a note on php.net about doing this with https.

So in the end my code looked like (no closing php tag intentional):

<?php
$url = "https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8";
$data = $_POST;
$data = http_build_query($data);
$result = do_post_request($url, $data);
echo $result;

function do_post_request($url, $data, $optional_headers = null)
{
   $params = array('http' => array(
                'method' => 'POST',
                'header'=> "Content-type: application/x-www-form-urlencoded\r\n"
	                . "Content-Length: " . strlen($data) . "\r\n",
                'content' => $data
             ));
   if ($optional_headers !== null) {
      $params['http']['header'] = $optional_headers;
   }
   $ctx = stream_context_create($params);
   $response = file_get_contents($url, false, $ctx);
   if ($response === false) {
      throw new Exception("Problem reading data from $url, $php_errormsg");
   }
   //var_dump($response);
   return $response;
}

October 15, 2008

Python and PHP serialization

Filed under: dev, php, python, tool — michaelangela @ 5:57 pm

I have some data that I am pulling via Amara. I need to put that in a database. The app that uses that data is in PHP and would prefer the data to be serialized. Fortunately, there is help! 🙂

Scott Hurring: Code: Python: PHP Serialize implemented in Python: v0.4b

This is a python implementation of PHP’s native serialize()
and unserialize() functions.

Taken along with my perl serialize implementation,
this code will enable you to transfer simple data structures
between PHP, Python, and Perl using PHP’s data serialization format.

This code aims to be a very lightweight data transport
layer between PHP, perl and python using PHP’s native
serialization format.

September 20, 2008

Adding a PHP nature to a project

Filed under: cool, php, tip, tool — michaelangela @ 12:55 am

I have a remote project already online and the PHP project type functions weren’t working, i.e. the PHP Explorer, the Outline view, Command(Ctrl) clicking an item to jump to it’s definition, etc. Those are really helpful! Not to mention auto completion! What was needed was the .project file on the server had to be updated to have the PHP nature suc as that below. That did the trick. Just make sure the tag has the real name of your project.

I haven’t tried adding Include Path’s though so that’s another issue altogether. Can’t get the code to display quite right… trying again…

[news.eclipse.tools.pdt] Remote System Explorer + Include Path


<?xml version="1.0" encoding="UTF-8"?>

<projectDescription>

<name>MyProj</name>

<comment></comment>

<projects>

</projects>

<buildSpec>

<buildCommand>

<name>org.eclipse.php.core.PhpIncrementalProjectBuilder</name>

<arguments>

</arguments>

</buildCommand>

<buildCommand>

<name>org.eclipse.wst.validation.validationbuilder</name>

<arguments>

</arguments>

</buildCommand>

</buildSpec>

<natures>

<nature>org.eclipse.php.core.PHPNature</nature>

</natures></projectDescription>


September 5, 2008

OS X, XDebug, MAMP, Zend Optimizer

Filed under: php, tip — michaelangela @ 1:48 am

It’s true… disable the Zend Optimizer. I had the same issue and this resolved it.

Installing XDebug with Mac OS X MAMP: disable PHP Zend Optimizer | AgaricDesign.com

After getting rid of (commenting out) the three lines about Zend optimizer in php.ini, it failed a couple times but then started working.

Recursive grep on OS X

Filed under: php, tip — michaelangela @ 1:24 am

grep -nr -C2 text *

July 20, 2008

Codeigniter Excel and PHP’s Spreadsheet Excel Writer Pear Package and how to not have to use PEAR

Filed under: codeigniter, cool, php, tip, xls — michaelangela @ 3:08 am

Well that’s a long title but it sums it up. I wanted to generate Excel from Codeigniter. Because of that I needed a way to use it whether or not PEAR is running/installed, etc. My local dev box doesn’t (yet) have it but that’s a story for another time.

The talented developers at Pizza SEO repackaged one of the recent versions of Spreadsheet Excel Writer as a set of classes together. No PEAR, no installing of separate items, etc. Normally I would like PEAR and it is on the deployment server but I wanted a portable flexbile version that worked within CodeIgniter and this fit the bill. Give them a visit! 🙂

PHP Excel Creator library | Pizza SEO

Pizza SEO has developed library for writing Excel (XLS) documents in PHP from former PEAR class Spreadsheet Excel Writer (see PEAR). We have cleaned this class, so PEAR installation is not required anymore and class is available as the standalone class.

July 14, 2008

A good short-list of PHP frameworks

Filed under: dev, mvc, php — michaelangela @ 7:08 am

I have had to come back to PHP after a long hiatus. I prefer Python but recent projects require PHP and thus my return. I did a project recently with CodeIgniter which really is a spiffy project. But I would like a true OOP PHP5 MVC fast lightweight framework that has user auth, session management and a lightweight ORM. Or be able to plug one in. Perhaps Kohana, based off of CodeIgniter, would fit the bill. Something about “Keep Kohana Alive” makes a little nervous though…

PHP: MVC Based Popular Framworks | Jit V. Tiwari

PHP: MVC Based Popular Framworks

April 20, 2008

1and1 and http compression

Filed under: 1and1, gzip, modrewrite, php, snippet, tip, tool — michaelangela @ 12:11 am

I have not been able to find any info about 1and1 and http compression. It’s a shame as it really reduces bandwidth, increases transfer speed, etc. Fortunately this little script does a really nice job of it. It’s in PHP and it works a treat on 1and1. With a bit of rewrite magic I should be able to access the files normally and the gzipped ones will be passed in when needed. Nice.

Julien Lecomte’s Blog » Gzip Your Minified JavaScript Files

If your web hosting company does not offer HTTP compression, but gives
you access to PHP (that’s the case of Yahoo! Web Hosting), I wrote a simple PHP script that will compress files and set the cache control headers so that the requested files actually get cached by the browser.

January 3, 2007

PHPit – Totally PHP : Taking a look at ten different PHP frameworks

Filed under: php — michaelangela @ 8:19 am

A breakdown of 10 PHP frameworks, comparisons, etc.

PHPit – Totally PHP :Taking a look at ten different PHP frameworks:

PHP frameworks are the latest hot topic in the PHP community, and new frameworks are being released daily. With over 40 frameworks available it’s difficult to decide which framework works best for you, especially as each framework offers different functionality.

In this article we will look at ten popular frameworks, and compare them to each other. First I will give you a general chart which gives you a quick overview of all the frameworks, and after that we’ll go through each framework and discuss it in short.

December 28, 2006

Simple Solution for secure logins | drupal.org

Filed under: dev, php — michaelangela @ 7:48 am

Simple solution for secure logins | drupal.org:

Here’s a simple way to do secure login that doesn’t require any patching to the Drupal core modules:

Quickfile | drupal.org

Filed under: dev, php — michaelangela @ 6:07 am

Too bad this wasn’t out a year ago! Aiya! But there would still need to be a good deal of custom code to be done. Perhaps we can help contribute to this project though.

Quickfile | drupal.org:

The Quickfile module allows instant selling and download of digital products such as ebooks, photographs, music and software. Clients don’t need to be registered to buy and they are sent to a page with a link to start downloading right after making their payment.

December 21, 2006

Re: [support] how to make drupal admin section https only?

Filed under: dev, php — michaelangela @ 11:15 am

Just a note about securing the login for a Drupal site.

Re: [support] how to make drupal admin section https only?:

A friend passed this code on to me and I am sorry to say I am not sure where it came from originally, but I have greatly benefited from it on my Drupal sites. Just replace the base url line in sites/default/settings.php with this code:

November 18, 2006

Hardened-PHP Project – PHP Security – Suhosin

Filed under: dev, php — michaelangela @ 9:28 am

Just saw it, saving for reference, and this probably only works on totally configurable installs. Even so, good to know.

Hardened-PHP Project – PHP Security – Suhosin:

Suhosin is an advanced protection system for PHP installations. It was designed to protect servers and users from known and unknown flaws in PHP applications and the PHP core.

November 17, 2006

SourceForge.net: XML-RPC Client for ActionScript 2

Filed under: dev, flash, php — michaelangela @ 3:37 pm

Mmm… Drupal, WordPress… Oodle anyone? Interesting.

SourceForge.net: XML-RPC Client for ActionScript 2:

XML-RPC can save Flash developers hours of work. It enables Flash to talk to blogs like WordPress and Blogspot. It also works with CMS’s that support XML-RPC like Plone/Zope and Drupal.

November 14, 2006

Why I think you shouldn’t use Cairngorm

Filed under: dev, php — michaelangela @ 7:02 am

Caringorm will be taking a back seat for a good little while. Plenty to learn in the mean time. 😛 I’ve already done the little test he mentioned, about using Flex 2 (with the free SDK version) and populating a Datagrid from a webservice (amfphp in this case) so that gives me hope. And yeah, I went from inline Actionscript to external classes… 😛

Steven Webster: Why I think you shouldn’t use Cairngorm

I know what you must be thinking – Steven Webster is suggesting I shouldn’t use Cairngorm ? Well no, not exactly. However, the rapid adoption of the Flex 2 platform that we are currently enjoying has seen us enjoy a tremendous number of new developers to the Flex platform, many of whom are trying to absorb as much information they can in as short a time as possible. When you first become aware of the tremendous opportunities for solution development with Flex, it’s no surprise that you want to ascend the adoption curve as quickly as possible. However, there’s no short-cut to experience, and that’s the topic I want to call out here. If you’re new to Flex 2 or Cairngorm, then I’d love for you to read on a little…

Integrated Development Experience

Filed under: dev, php — michaelangela @ 6:56 am

Getting Eclipse. Tried it out before with Java n-years ago. Pretty cool but no time to learn it. Trying again……….. phpclipse, subclipse, callisto… step by step

GhostWhoWalksInside » Blog Archive » Integrated Development Experience

you can put all things you need (like php/sql editor,console, outline,version browser, web browser, file tree) in one view and much much more.

November 13, 2006

Making Drupal Forums look like phpBB forums

Filed under: dev, php — michaelangela @ 7:57 am

This one is just theming only. The code would probably need to be updated for current Drupal installs though.

Making Drupal Forums look like phpBB forums | Drupal for Artists & Musicians

Here is a quick way to get your Drupal forums to look like phpBB forums using simple theming.

Drupal and phpBB integration test site

Filed under: dev, php — michaelangela @ 7:55 am

A client asked so we did some digging. Interesting and useful apparently! Will it work on current versions? Don’t know. Looks like it should though.

About this site | Drupal and phpBB integration test site

This site is a test-installation of the module that provideds integration between Drupal and phpBB, using Drupal as the master.

Create a free website or blog at WordPress.com.