Part of the EllisLab Network
   
2 of 3
2
amfphp with CI
Posted: 20 April 2008 01:56 PM   [ Ignore ]   [ # 16 ]  
Grad Student
Avatar
Rank
Total Posts:  44
Joined  03-15-2006

There doesn’t seem to be as much interest in this subject anymore. However, I added a more detailed description of the process in the wiki. This includes the Actionscript code used too. Amfphp and CI

Profile
 
 
Posted: 20 April 2008 04:43 PM   [ Ignore ]   [ # 17 ]  
Grad Student
Rank
Total Posts:  56
Joined  12-31-2004

Thanks Noinx… I may have a amfphp-type job coming up, so I appreciate the effort.

Profile
 
 
Posted: 20 April 2008 05:07 PM   [ Ignore ]   [ # 18 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  327
Joined  07-23-2006

I’m still working on my amfphp project, it all works now but I’ll definitely keep an eye on what you have to say. Always interested in better solutions.

 Signature 

running man webdesign

Profile
 
 
Posted: 20 April 2008 05:25 PM   [ Ignore ]   [ # 19 ]  
Grad Student
Rank
Total Posts:  68
Joined  04-11-2006

Noinx,

thanks very much for your work on this, but I cant seem to get this to function properly. I understand the concept of what you are doing with loading CI into the service and returning any data to the global value, but I am getting the following error from the remoting object in Flex

(mx.rpc::Fault)#0
  
errorID = 0
  faultCode
= "Client.Error.DeliveryInDoubt"
  
faultDetail = "Channel disconnected before an acknowledgement was received"
  
faultString = "Channel disconnected"
  
message = "faultCode:Client.Error.DeliveryInDoubt faultString:'Channel disconnected' faultDetail:'Channel disconnected before an acknowledgement was received'"
  
name = "Error"
  
rootCause = (null)

The gateway is installed correctly, and I can get Flex to register data if I return something before CI is included in the service class, but once I load CI it breaks as soon as the index.php file tries to include Codeigniter.php.

I havent been able to find much useful information on the net at all about this. Some people have mentioned the issue, but most of these seem to stem from incorrect installations of AMFPHP. As I mentioned the gateway is installed correctly and I can return information just fine, it is the CI integration that is causing the issues.

I am using CI 1.6.1 if that makes a difference at all. I have also run the service class by itself, and it works just fine when called directly from PHP.

Any ideas??

Also on a side note, I use CI and Flex a lot but use XML or JSON as the transport mechanism. This works really well but I am looking at some projects that require a lot of data to be moved around and AMF seemed like a good option.

James

Profile
 
 
Posted: 20 April 2008 06:58 PM   [ Ignore ]   [ # 20 ]  
Grad Student
Rank
Total Posts:  68
Joined  04-11-2006

OK,

I found the issue…. the fresh install of CI 1.6.1 still had error handling turned on (E^ALL), and AMFPHP doesnt like this very much…

So word to the wise, watch the error handling, or put in a conditional statement to watch for the AMFPHP variable and turn off the errors.

Thanks again NOINX and others for your work, this was most helpful.

James

Profile
 
 
Posted: 20 April 2008 11:05 PM   [ Ignore ]   [ # 21 ]  
Grad Student
Avatar
Rank
Total Posts:  44
Joined  03-15-2006

It’s good to see that there is still interest in CI and Amfphp.

I didn’t think to mention that I changed the error reporting in index.php for CI. Since I do it for every project it slipped my mind.

//error_reporting(E_ALL);
    
error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING);

I will have to do some testing with the default configuration.

CI 1.6.1 is the version used for testing.

Profile
 
 
Posted: 20 April 2008 11:15 PM   [ Ignore ]   [ # 22 ]  
Grad Student
Rank
Total Posts:  68
Joined  04-11-2006

Noinx,

My company (www.enilsson.com) does a lot of projects with Flex and CI. Actually all our projects are with CI and more and more are with Flex. So yes there is a lot of interest in AMFPHP, at least from my side.

James

Profile
 
 
Posted: 12 June 2008 09:10 AM   [ Ignore ]   [ # 23 ]  
Summer Student
Total Posts:  1
Joined  06-12-2008

hi everybody.

1) thanks to Noinx for this great tutorial.

2) i’m also trying to get this stuff working but still get some errors when using the controller.

i’m using CI 1.6.2 with AMFPHP 1.9beta.
i set everything as Noinx described before.

i’ve two methods in my action-service:

function execute($path, $vars=false)
{
   define
('AMFPHP', 1);

   global
$value;

   if(
$vars AND is_array($vars))
   
{
       
// Convert vars to POST data
       
$_POST = $vars;
   
}  
                          
   $_SERVER[
'PATH_INFO'] = '/'.$path;
   
$_SERVER['QUERY_STRING'] = '/'.$path;
   
$_SERVER['REQUEST_URI'] = '/'.$path;
        
   require_once(
'../../codeigniter/index.php');
        
   return
$value;
}
    
function hello($name)
{        
   
return "hello " . $name;
}

the controller looks like the one in the example:

if (!defined('AMFPHP')) exit('No direct script access allowed');

class
HelloWorld extends Controller {

    
function HelloWorld()
    
{
        parent
::Controller();
    
}
    
    
function index()
    
{
        
global $value;
        
$test = "result result result.";        
        
$value = $test;
    
}
}

the first one is trying to use a ci-controller but throws an error saying:
“DEBUG: amf::RemoteService - onNetStatus() NetConnection.Call.BadVersion”.

i’m also using CHARLES proxy to view what’s going on between flash and amf-getaway and it says:
“Failed to parse data (...) unsupported AMF version or corrupted data: 8205”

if i check the RAW-response in CHARLES it just looks like any other amf response only i think there is an extra newline before the result - is this what’s causing all the trouble?

when i call the second method (“hello”) - i get the correct result “hello XXX”. so gateway etc are set up correctly.

maybe someone can shed some light ....?

thanks.
phil

Profile
 
 
Posted: 12 June 2008 10:53 AM   [ Ignore ]   [ # 24 ]  
Grad Student
Avatar
Rank
Total Posts:  44
Joined  03-15-2006

This tutorial was added to the wiki awhile back, with more detail. You can find it here: Amfphp and CI
It was updated by another user, but at a quick glance, I can’t tell if changes were made.

I haven’t tried using CI 1.6.2 yet. I will post here when I do.

Check all of your php files and remove extra lines and spaces before and after the php tags. This happend to me in the hook file. The result still made it to Charles, but caused an error in Flex.

Also, make sure your character set is correct in the gateway.php file.

This page on amfphp.org should help you to narrow down the problem. Amfphp Docs

-Noinx

Profile
 
 
Posted: 20 June 2008 08:18 AM   [ Ignore ]   [ # 25 ]  
Grad Student
Avatar
Rank
Total Posts:  44
Joined  03-15-2006

The process above works fine in CI 1.6.2. No modifications are needed.

Profile
 
 
Posted: 01 July 2008 12:31 PM   [ Ignore ]   [ # 26 ]  
Summer Student
Total Posts:  6
Joined  06-04-2008

What about 1.6.3? I can’t seem to get it working? Amfphp doesn’t return anything!Please help me!
Also couldn’t this be modified so that we don’t need to pass as a parameter the controller and the function?
I need this badly for one project! Please help!

Profile
 
 
Posted: 01 July 2008 12:46 PM   [ Ignore ]   [ # 27 ]  
Summer Student
Total Posts:  6
Joined  06-04-2008

Couldn’t we add a function like render_amf or send_amf to Controllers and when this function is called header to be disabled and phpamf notice that controller is a service and to take the result. Any idea how this could be implemented?

Profile
 
 
Posted: 01 July 2008 03:27 PM   [ Ignore ]   [ # 28 ]  
Grad Student
Avatar
Rank
Total Posts:  44
Joined  03-15-2006

Works great on 1.6.3. If you don’t have the Charles Debugger, get it here: Charles Debugger. This program will help you determine what the gateway is sending back, like an error. Remember that with this solutions, loading most libraries must be done in the autoload config file or in the constructor of the controller.

As far as not passing the controller and function names, you could use routes instead. I like passing these values to make tracking down errors easier.

I would like to see AMF integrated into CI. It took me many months to come up with this solution. Hopefully someone with a better working knowledge of AMF and CI is working on something.

Profile
 
 
Posted: 02 July 2008 08:41 AM   [ Ignore ]   [ # 29 ]  
Summer Student
Total Posts:  6
Joined  06-04-2008

Thanks I’ll check it. I will also look into cakephp and seagull integration maybe it can adjusted to to
CI!

Profile
 
 
Posted: 08 August 2008 02:06 PM   [ Ignore ]   [ # 30 ]  
Summer Student
Total Posts:  10
Joined  07-18-2008

Hello

The info here has been great and everything is working perfectly as documented.

One question - how do I pass arguments to my remote methods? Is this supported?

For example, if I have a php class like this for my controller (using the examples). I’ve changed the func controller method to take a single argument.

<?php

// test amfphp controller

if (!defined('AMFPHP')) exit('No direct script access allowed');

class
Cont extends Controller {

    
function Cont()
    
{
        parent
::Controller();
    
}
    
    
function func($param=null)
    
{
        
global $value;
        
        
$returnVal = 'param is unknown type';
        if (
is_array($param))
            
$returnVal = "param is array";
        else if (
is_string($param))
            
$returnVal = "param is string";
        else if (
is_numeric($param))
            
$returnVal = "param is numeric";
        else if (
is_null($param))
            
$returnVal = "param is null";
        
        
$value = $returnVal; // $value can be any data type. If it's an array, it should be sent back as an array collection.
    
}
    
}
?>


On the flash side, I’m attempting to send an array of strings as an argument from flash (this is using the example HellowWorld example that comes with amfphp-1.9.beta). I was expecting the sent from here to show up as a parameter to the php function, but it returns null in all cases.

// Method run when the "Send To Server" button is clicked.
public function sendData(e:MouseEvent):void {
    trace
("Sending Data to AMFPHP");
    
// Get the data from the input field
    
var params = server_txt.text;
            
    var
params2:Array = new Array();
    
params2.push("dog");
    
params2.push("dog1");
    
params2.push("dog2");
            
    
// Send the data to the remote server.
    
connection.call("action.execute", responder, "cont/func", params2);
}


In the flash docs, it says I can pass a variable number of parameters to the remote function call here.


Anybody know how to make this work?

Thanks,

August

Profile
 
 
   
2 of 3
2
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 819, on March 11, 2010 11:15 AM
Total Registered Members: 120471 Total Logged-in Users: 30
Total Topics: 126548 Total Anonymous Users: 4
Total Replies: 665393 Total Guests: 286
Total Posts: 791941    
Members ( View Memberlist )