Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Anas Anjaria
    @anasanjaria

    but I want something like

    { "header": { "code": my_code, "message": my_message_or_set_via_annotations }, "body": my_body }

    actually my whole application has generic response
    Arul
    @Arul-
    @anasanjaria thats very easy
    Composer class is responsible for that
    create your own Composer class by implementing iCompose interface
    use the Composer class that comes with Restler as an example
    just alter the error response structure
    Then set
    Luracast\Restler\Defaults::$composeClass = ‘MyOwnCompose’;
    thats all
    Anas Anjaria
    @anasanjaria
    thanks @Arul-
    Csiszár Attila
    @csiszarattila

    hi
    i need little advise on annotations:

    Is it possible to annotate that i'm returning an array of models, and show model attributes on explorer under "Response Class"

    Eg:

    /** 
     * @return array (@class Users)
     */
    public function index()
    {
        return [
            new User(),
            new User(),
        ];
    }

    Thanks!

    Arul
    @Arul-
    /** 
     * @return array {@type User}
     */
    public function index()
    {
        return [
            new User(),
            new User(),
        ];
    }
    Csiszár Attila
    @csiszarattila
    Okay, thanks, it working.
    And what about showing the model attributes in the explorer, is it possible?
    Arul
    @Arul-
    which version of restler is being used? RC5 or RC6?
    Csiszár Attila
    @csiszarattila
    RC6
    Csiszár Attila
    @csiszarattila

    Okay, another problem: I cant get to show a blank request on POST/PUT in explorer

    in Restler i use:
    /**

     * @param string $name {@from body}
     */
    public function put($name)
    {    
    }

    in explorer i want to appear a blank json request under parameters:

    {
        "name" : ""
    }
    Sean Goresht
    @srsgores
    hey guys
    anyone there?
    Arul
    @Arul-
    @csiszarattila not sure I understand what you want! Could you explain a bit more?
    @srsgores even if you dont find any one when you are trying just post your question, it will be answered soon!
    Oleg Melnik
    @olegmelnik
    "debug": {
    "source": "Routes.php:431 at route stage",
    "stages": {
    "success": [
    "get"
    ],
    Arul
    @Arul-
    @olezko46 I guess you are getting 404 as Routes class could not find a route for the given url
    Matt Grosse
    @mattgrosse
    i'm getting undefined index notices here: vendor/Luracast/Restler/Routes.php on line 242
    which seems to be related to this: Luracast/Restler#416
    i'm using php 5.4
    Kit Sunde
    @kitsunde

    Looking at the live examples it doesn't seem like they are using require_once to import the APIClasses, but in my application I have to otherwise it seems like $r->addAPIClass('Foo') doesn't make that routable. How do I prevent this from happening:

    <?php
    include_once './vendor/autoload.php';
    include_once 'Foo.php';
    include_once 'Bar.php';
    include_once 'Baz.php';
    
    use Luracast\Restler\Restler;
    $r = new Restler();
    $r->addAPIClass('Foo');
    $r->addAPIClass('Bar');
    $r->addAPIClass('Baz');
    $r->handle();

    i.e. how do I stop needing to include every one of my API classes.

    Also I really wish that addAPIClass threw an exception if it can't find an APIClass. I probably spent 2 hours going through the source trying to figure out why it wasn't routing until I realized the include was missing.
    Arul
    @Arul-
    @kitsunde noted! will get back to you on the possibilities soon!
    byte.it
    @letsbyteit
    Did I get this right? Swagger 2.0 requires 'Schema'-Array for parameters located in the body? And this is currently missing in the S2-FeatureBranche, right?
    byte.it
    @letsbyteit
    Btw, I made it Swagger 2.0 compatible by adding the schema-array and change the defaultValue property to default. My code isn't really nice, but I'm going to fork the feature branch. And also, I think it's important to disable the HTML markup in the Swagger-Spec.
    Kit Sunde
    @kitsunde
    I'm using @format UploadFormat, but I can't for the life of me get it to respond with anything. I end up doing this:
      /**
       * @status 201
       * @url POST upload
       * @format UploadFormat
       * @access public
       * @throws RestException
       */
      function upload()
      {
        $media = CmsMedias::createMedia($_FILES['file']);
        header("Content-Type: application/json");
        echo json_encode(["media_id" => $media->getMediaId()]);
        exit();
      }
    While I actually want to do this:
    return ["media_id" => $media->getMediaId()];
    Kit Sunde
    @kitsunde
    Can I make Restler not eat the stack trace? I'd like to see my exceptions.
    Arul
    @Arul-
    Use your own Composer class to do that
    Jesse Weigert
    @jesseweigert
    @kitsunde I have one if you would like it.
    Jesse Weigert
    @jesseweigert
    This message was deleted
    Arul
    @Arul-
    Nice work @jesseweigert :+1:
    devnoname120
    @devnoname120

    Hello, I cannot access the command line on my server so I cannot install Composer and Restler in a conventional way. I created a local web server and I set up everything. Accessing http://localhost/HomebrewLand/public/examples/_001_helloworld/index.php/say/hello works correctly.

    Now I uploaded the project to my server, and when I write the same URL, I have the following error:

    
    Warning: Class 'Luracast\Restler\Restler' not found in /var/www/legtux.org/users/devnoname120/www/HomebrewLand/vendor/restler.php on line 6
    
    Fatal error: Class 'Luracast\Restler\Restler' not found in /var/www/legtux.org/users/devnoname120/www/HomebrewLand/public/examples/_001_helloworld/index.php on line 18

    Do you know how I could fix it?

    devnoname120
    @devnoname120

    If I modify the following line of vendor/restler.php

    if (is_readable(__DIR__ . '/autoload.php')) {

    to

    if (false && is_readable(__DIR__ . '/autoload.php')) {

    then it uses the other loader and it works. But it doesn't seem to be a proper solution (and could create issues later), so I would like to fix my issue anyway.

    byte.it
    @letsbyteit
    Anything about documentation for model-usage yet?

    I got this model-code so far:

    <?php
    
    namespace API\Models;
    
    
    use Luracast\Restler\Data\ValueObject;
    
    
    /**
     * Class Client
     *
     * A demo for model usage
     *
     * @package API\Models
     */
    class Client extends ValueObject
    {
        /**
         * @var int $id The id of the client
         */
        public $id;
    
        /**
         * @var string $surname The surname of the client
         */
        public $surname;
    
        /**
         * @var string $firstName The first name of the client
         */
        public $firstName;
    
        /**
         * @var string $emailAddress The e-mail address of the client {@type email}
         */
        public $emailAddress;
    
        /**
         * @var int $age The age of the client
         */
        public $age;
    }

    Then the API Class very simple:

    <?php
    
    namespace API\Clients;
    
    
    use API\Models\Client;
    
    
    /**
     * Class Clients
     *
     * Demonstrate the Model Usage
     *
     * @package API\Clients
     */
    class Clients
    {
        /**
         * Retrieves a client by using the Client-Model
         *
         * @param int $id
         *
         * @return Client
         */
        public function getClient($id)
        {
            $client = new Client();
            $client->id = $id;
            $client->age = 42;
            $client->surname = "Doe";
            $client->firstName = "John";
            $client->emailAddress = "john.doe@umbrella.inc";
    
            return $client;
        }
    
        /**
         * Creates client by using the Client-Model
         *
         * @param Client $client
         *
         * @return Client
         *
         * @status 201
         */
        public function postClient($client)
        {
            return $client;
        }
    
    }

    This "works", but there is no validation done on the Model-Object passed by the POST?

    byte.it
    @letsbyteit
    Screen Shot 2016-09-28 at 19.39.20.png
    You see? I passed an invalid email address and a string as ID
    There is also a related issue on github: Luracast/Restler#506
    byte.it
    @letsbyteit
    And am I understanding this correct: ValueObject is capable of creating an object (eg. Client) itself if I pass the properties or so? If I run a database query in a GET and want to return some Client-Rows, can this class ValueObject convert them into real Client-Objects to output them? Should this be done or is that more a senseless thing that increases response time?
    Chetan-citrusbug
    @Chetan-citrusbug
    i have one issue when i am sending json some time it's accept it and some time not and gives 500 error
    I also posted this to git hub. You guys can check using there using link: Luracast/Restler#586