Go Back   ZeroC Forums > Comments

Reply
 
LinkBack Thread Tools Rate Thread Display Modes
  #1 (permalink)  
Old 10-04-2005
PeteH PeteH is offline
Registered User
 
Name: Peter Hug
Organization: Warehouse Optimization LLC
Project: APAL
 
Join Date: Oct 2004
Location: Napier, New Zealand
Posts: 26
Developing a FileSystem Client in PHP

I don't understand why this topic is missing in your otherwise fairly extensive documentation?!?!

I'm not a PHP programmer but I need to evaluate ICE to implement an interface accross processor boundaries between a C++ server and Python/PHP clients.

I wonder if you have a PHP sample implementation of the basic FileSystem client resembling the functionality implemented in C++ and explained chapter 7?
Reply With Quote
  #2 (permalink)  
Old 10-04-2005
mes's Avatar
mes mes is offline
ZeroC Staff
 
Name: Mark Spruiell
Organization: ZeroC, Inc.
Project: Ice Developer
 
Join Date: Feb 2003
Location: California
Posts: 971
Please see this thread for information on our forum support policy:

Important note: Change in support policy
Reply With Quote
  #3 (permalink)  
Old 10-04-2005
PeteH PeteH is offline
Registered User
 
Name: Peter Hug
Organization: Warehouse Optimization LLC
Project: APAL
 
Join Date: Oct 2004
Location: Napier, New Zealand
Posts: 26
Do you like this better?
__________________
Peter Hug
Warehouse Optimization LLC (http://www.warehouseoptimization.com)
Reply With Quote
  #4 (permalink)  
Old 10-04-2005
PeteH PeteH is offline
Registered User
 
Name: Peter Hug
Organization: Warehouse Optimization LLC
Project: APAL
 
Join Date: Oct 2004
Location: Napier, New Zealand
Posts: 26
Attached is a smal sample that I wrote but at present I get the error:

Fatal error: listRecursive(): unknown operation in c:\oracle\ora91\Apache\Apache\htdocs\filesystemcli ent.php on line 41

I can't see what is wrong.
Attached Files
File Type: zip FileSystemClient.zip (696 Bytes, 78 views)
__________________
Peter Hug
Warehouse Optimization LLC (http://www.warehouseoptimization.com)
Reply With Quote
  #5 (permalink)  
Old 10-04-2005
mes's Avatar
mes mes is offline
ZeroC Staff
 
Name: Mark Spruiell
Organization: ZeroC, Inc.
Project: Ice Developer
 
Join Date: Feb 2003
Location: California
Posts: 971
Thanks Peter.

We don't have a good reason for omitting the filesystem example in PHP. We'll add this to the manual.

Here is the PHP code for the client:
Code:
<?php
Ice_loadProfile();

// Recursively print the contents of directory "dir"
// in tree fashion. For files, show the contents of
// each file. The "depth" parameter is the current
// nesting level (for indentation).

function listRecursive($dir, $depth = 0)
{
    $indent = str_repeat("\t", ++$depth);

    $contents = $dir->_list(); // list is a reserved word in PHP

    foreach ($contents as $i) {
        $dir = $i->ice_checkedCast("::Filesystem::Directory");
        $file = $i->ice_uncheckedCast("::Filesystem::File");
        echo $indent . $i->name() .
            ($dir ? " (directory):" : " (file):") . "\n";
        if ($dir) {
            listRecursive($dir, $depth);
        } else {
            $text = $file->read();
            foreach ($text as $j)
                echo $indent . "\t" . $j . "\n";
        }
    }
}

try
{
    // Create a proxy for the root directory
    //
    $base = $ICE->stringToProxy("RootDir:default -p 10000");

    // Down-cast the proxy to a Directory proxy
    //
    $rootDir = $base->ice_checkedCast("::Filesystem::Directory");

    // Recursively list the contents of the root directory
    //
    echo "Contents of root directory:\n";
    listRecursive($rootDir);
}
catch(Ice_LocalException $ex)
{
    print_r($ex);
}
?>
Take care,
- Mark
Reply With Quote
  #6 (permalink)  
Old 10-04-2005
mes's Avatar
mes mes is offline
ZeroC Staff
 
Name: Mark Spruiell
Organization: ZeroC, Inc.
Project: Ice Developer
 
Join Date: Feb 2003
Location: California
Posts: 971
Quote:
Originally Posted by PeteH
Attached is a smal sample that I wrote but at present I get the error:

Fatal error: listRecursive(): unknown operation in c:\oracle\ora91\Apache\Apache\htdocs\filesystemcli ent.php on line 41

I can't see what is wrong.
You need to change $objDir->list() to $objDir->_list(). Since "list" is a reserved word in PHP, the Slice mapping prepends an underscore to its name. You can find a list of PHP's reserved words here:

http://www.php.net/manual/en/reserved.php

Take care,
- Mark
Reply With Quote
  #7 (permalink)  
Old 10-04-2005
PeteH PeteH is offline
Registered User
 
Name: Peter Hug
Organization: Warehouse Optimization LLC
Project: APAL
 
Join Date: Oct 2004
Location: Napier, New Zealand
Posts: 26
That's it - my page works now. Thanks for your help.
__________________
Peter Hug
Warehouse Optimization LLC (http://www.warehouseoptimization.com)
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Perhaps an error in Filesystem example albertods Bug Reports 2 03-14-2006 08:24 AM
C# FileSystem from book stephenhardeman Help Center 1 08-17-2004 11:52 PM
some design issue on distributed filesystem soloman817 Help Center 1 07-13-2004 06:39 PM
filesystem implementation/ followup to my previous question stephan Help Center 11 07-08-2004 07:12 PM
FileSystem Client Compile Warning amrufon Help Center 2 07-29-2003 11:31 PM


All times are GMT -4. The time now is 08:58 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0
(c) 2008 ZeroC, Inc.