[FX.php List] Re: FX.php_List Digest, Vol 33, Issue 15

John Lannon jlannon at gmail.com
Fri Apr 13 13:28:32 MDT 2007


Hey Dan,

Thanks a lot for the post, it's an extremely useful contribution. I've been
using CI with Filemaker and other backends for several projects in the past
year and am glad to see that others are starting to adopt web application
frameworks. I personally don't know how I used to build web apps without CI
(or Rails or CakePHP, take your pick).

In any case, I definitely think you should submit your tutorial to the CI
wiki and to other Filemaker forums as well. I spent a bit of time tooling
with the FX class and using a new constructor for CI, but scrapped that idea
(not OO enough, I guess).  Wrapping FX in the CIFX class makes sense and
conforms to PHP's OO standards. I would definitely like to use your idea in
future projects ...

The only thing I would add is that by passing the basic parameters to CIFX
via the configuration file, one would tie oneself to a single data source.
Although I would imagine that most users would only use one data source (
i.e., one Filemaker Server machine), I've been on a project or two in which
multiple Filemaker sources are used. In this case, the static config file
would be insufficient. I'd have to check the most recent CI docs, but I
believe one can pass configuration arguments to their library directly
(bypassing the default config file), but by doing so, the config file
becomes inaccessible. So, I would add a note to your step 4 mentioning this.


I have been working on a web resource that provides information about
integrating Filemaker with web development frameworks. If you're interested
in helping out, please feel free to email me.

Thanks,
John Lannon

Anvil Automation
http://www.anvilautomation.com

Message: 5
> Date: Fri, 13 Apr 2007 12:29:59 -0400
> From: DC <dan.cynosure at dbmscan.com>
> Subject: [FX.php List] REDO-FX.php as a Library in CodeIgniter
>         framework
> To: "FX.php Discussion List" < fx.php_list at mail.iviking.org>
> Message-ID: <461FB007.9010609 at dbmscan.com>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> Hi,
>
> OO-ps... I didn't follow OO practices when submitting my integration
> technique. I've redone steps 3, 4, and 5 so that you do not modify
> FX.php at all - you simply extend it using PHP's OO capability. The full
> instructions with (easier) redone steps follow.
>
> -------------------------------------------
> I put together what I think is the cleanest integration possible between
> FX.php and CodeIgniter (CI). It's pretty easy to do.
>
> If you are looking for a good way of expanding your PHP horizons,
> CodeIgniter is a good way to do it. If you haven't seen CodeIgniter,
> head over to http://codeigniter.com to check it out. In short, it is a
> PHP Framework that helps you organize code and offers nice integrated
> libraries. It is also PHP4 and 5 friendly, highly object-oriented, and
> extendable.
>
> I've been testing out FX.php with CI and I like it a lot.
>
> Here's how I got my set up working:
>
> 1) Download, install and configure CI per the very good instructions at
> the site. If you have problems, the CI forum is helpful. It should take
> less than an hour for an intermediate PHP person to get to hello world
> (welcome_message.php). Time: 1 hour.
>
>
>
> 2) Once you've got CI running, put the latest copy of FX.php,
> FX_Error.php, and FX_constants.php in CI's application/libraries/
> directory. Time: 5 minutes tops.
>
> ....THIS STEP CHANGED from previous message....
> 3) Drop this class extension into the same directory with FX.php (CI's
> application/libraries/ directory).
>
> <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
>
> /*------------------------------------------------------------------*/
> // DEC 20070413 wrapper for CI integration
> // needs to be able to init with params in an array
> // load these using config file FX.php
> /*------------------------------------------------------------------*/
> require('FX.php');
>
> class CIFX extends FX {
>
>         function CIFX ($params)
>         {
>                 parent::FX(
>                 $params['dataServer'],
>                 $params['dataPort'],
>                 $params['dataType'],
>                 $params['dataURLType']
>                 );
>         }
>
> }
>
> ?>
>
> This class extension for FX.php lets CI load FX.php with an array as an
> argument. External libraries like FX.php need no direct modifications to
> integrate with CI properly - just extend them with a wrapper function
> that accepts arrays and passes them on.
>
> In summary, you need a new class called CIFX which will be the new
> constructor. It translates the array passed in by the CI class loader
> into the 4 parameters the normal FX.php constructor can understand.
>
> Time: Another 5 minutes, tops.
>
>
>
> ....THIS STEP CHANGED from previous message...
> 4) Make a file called CIFX.php (the same name as the class so CI can
> load it automatically) and put it in CI's application/config/ directory.
> It should contain the data that is normally found in server_data.php in
> the FX.php distribution but formatted like a PHP file like this:
>
> <?php  if (!defined('BASEPATH')) exit('No direct script access allowed');
>
> /*
>
> |--------------------------------------------------------------------------
> | FX FMP database access data
>
> |--------------------------------------------------------------------------
> */
>
> $config['dataServer']=' 127.0.0.1';
> $config['dataPort']='591';
> $config['dataType']='FMPro5/6'; // or FMPro7
> $config['dataURLType']='http';
>
> ?>
>
> CI will load this data and pass it to the new CIFX.php class constructor
> for you - it can do that because the names are the same. Time: 5 more
> minutes.
>
>
>
> ....THIS STEP CHANGED from previous message...
> 5) Almost there... make a "controller" file called "search.php" and put
> it in the application/controllers/ directory with this PHP code (modify
> the database, layout and field data):
>
> <?php
>
> class Search extends Controller {
>
> function Search()
> {
>         parent::Controller();
> }
>
> function id($id)
> {
>         // CI knows where to find the
>         // CIFX.php FX wrapper file at
>         // CI path: application/libraries/CIFX.php
>         // FMP WPE data (IP, port, server version,
>         // and url scheme) is in custom config file at
>         // CI path: application/config/CIFX.php
>         $this->load->library('CIFX');
>         // tell FX which DB, layout to use and
>         // how many records to return
>         $this->cifx->SetDBData('database.fp5', 'layout', 1);
>         // build a find request, field name, data, comparison
>         $this->cifx->AddDBParam ('id', $id, 'eq');
>         // do find, return dataset, no flattening, meta object
>         $res = $this->cifx->DoFXAction(FX_ACTION_FIND, TRUE, TRUE);
>         echo '<pre>';
>         print_r($res);
>         echo '</pre>';
> }
> }
> ?>
>
> This AddDBParam example assumes you have a database with the fieldname
> 'id' - you, of course, can change that to suit. I suggest just pointing
> the FX requests to a database you've already got set up and working.
> Time: If you use a database already set up, 5 minutes to modify this
> code and fire it up.
>
>
> 6) Point your browser to:
> http://example.com/path_to_CI/index.php/search/id/1
>
> Note: if you followed the CI install instructions on how to use an
> .htaccess file to use mod_rewrite for nice urls, then you can drop the
> index.php and just use:
>
> http://example.com/path_to_CI/search/id/1
>
> ....THIS DESCRIPTION CHANGED from previous message...
> CI takes the URL segments and loads one as a controller file (search),
> calls one as a function (id), and passes the last one as a variable (1)
> for your id() controller function to use as a search parameter. Nice and
> sweet. It's a great way of organizing projects!
>
> Let me know if you have problems with this. I'd like to get a little
> feedback from the FX folks first and then post instructions at the CI
> forums.
>
> Did it take you an hour and 20 minutes? Let me know!
>
> dan
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.iviking.org/pipermail/fx.php_list/attachments/20070413/c7cb69ee/attachment.html


More information about the FX.php_List mailing list