Luracast / Restler

Simple and effective multi-format Web API Server to host your PHP API as Pragmatic REST and/or RESTful API
http://luracast.com/products/restler/
GNU Lesser General Public License v2.1
1.36k stars 316 forks source link

Unable to correctly return primitive types #366

Closed bohemima closed 10 years ago

bohemima commented 10 years ago

Re-visiting #295, this does not work correctly in neither RC5, 6 or dev-master

class Answer {
    /**
     * Simply returns 42.
     *
     * @return int
     */
    public function universe() {
        return 42;
    }
}

$r = new Restler();
$r->addAPIClass('Resources');
$r->addAPIClass('Answer');
$r->handle();

But responseClass remains "void"

Arul- commented 10 years ago

Are you using the Explorer class instead of Resources in RC-6?

<?php

class Register {

    /**
     * @return int
     */
    public function get(){
        return 52;
    }

} 
use Luracast\Restler\Restler;
$r = new Restler();
$r->addApiClass('Register');
$r->addApiClass('Explorer');

int-type

bohemima commented 10 years ago

My bad Arul, it does work using the Explorer resource, however not in RC5 using Resources as described in #295 (should it work)?

I will start adopting RC6 soon enough anyway, thanks for all your effort!