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
    Arul
    @Arul-
    ok
    Arul
    @Arul-
    there is no AccessControl in the repo
    Anas Anjaria
    @anasanjaria
    wait plz
    here it is
    Arul
    @Arul-
    ok will check and get back to you tomorrow
    ok no problem
    Anas Anjaria
    @anasanjaria

    @Arul- I try to debug the code & comparing the same code with working copy of example of restler ( core i.e without laravel structure ) .

    I altered composer.json file in my existing code based on laravel type structure & removed "": "app/custom" from autoload ( ps0 ) .. `

    Now its not throwing that notice any more i.e PHP Notice: Undefined index: AccessControl ... as described above ..

    But what I figured out is $r->addAuthenticationClass('AccessControl'); does not have any impact on code. What am I trying to say is even writing die('aaa') under __isAllowed function of AccessControl does not print aaa on screen/console log .

    I try to override Restler framework of sample project containing examples with that of my laravel structure & it produces the same issue with examples too i.e Authentication class have no impact on code.
    I think your last changes on git might be creating a problem .. am not sure but I think so ..
    Anas Anjaria
    @anasanjaria
    I have commited my latest code on (github)[https://github.com/anasanjaria/framework/commits/authentication]
    Arul
    @Arul-
    @anasanjaria I’m pushing an update that fixes it
    Anas Anjaria
    @anasanjaria
    @Arul- thanks it works :smile:
    Anas Anjaria
    @anasanjaria

    @Arul- is it possible that I can use https://packagist.org/packages/illuminate/hashing in restler + laravel DB structure ??

    Here is what I done so far.

    alter composer.json file

    "illuminate/hashing": "4.2.*"

    alter app.php file under config

    'providers' => array( ......... 'Illuminate\Hashing\HashServiceProvider' ),

    'aliases' => array(
    ....
    'Hash' => 'Illuminate\Support\Facades\Hash'
    )`

    & its not working here is the error

    PHP Fatal error: Call to undefined method Illuminate\\Support\\Facades\\Hash::make() in /path/to/folder/engine/vendor/illuminate/support/Illuminate/Support/Facades/Facade.php on line 208

    Is it possible or not ?

    Arul
    @Arul-
    will check and get back later
    Arul
    @Arul-

    @anasanjaria here is how to make it work

    require __DIR__ . '/../bootstrap/autoload.php';
    $providers = $app['config']['app.providers'];
    foreach ($providers as $class) {
        /** @var ServiceProvider $instance */
        $instance = new $class($app);
        $instance->register();
    }

    Service providers are initialised only for artisan by default. using the above code in your index.php you can get them initialized. then Hash::make will start working!

    Anas Anjaria
    @anasanjaria
    @Arul- thanks alot it works :smile:
    Anas Anjaria
    @anasanjaria

    @Arul- I need to know detail about access control / authentication layer

    I have checked the code provided in examples (https://github.com/Luracast/Restler/blob/master/public/examples/_010_access_control/AccessControl.php) but still am a bit confused ...

    I have following queries

    Is $requires necessary for Authentication class ?

    Actually I try to debug dd($m['class']['AccessControl']['properties']); under verifyAccess function, it shows requires param but when I add another property $level, dd($m['class']['AccessControl']['properties']); does not have any impact.
    Also when I altered the value of public static $requires = 'user'; to public static $requires = 'usdder'; it is not authenticating & gives the following response
    `
    @url http://localhost/restler/engine/public/resources.json?api_key=12345
    @response

    {
    "apiVersion": "1",
    "swaggerVersion": "1.1",
    "basePath": "http://localhost/restler/engine/public",
    "produces": [
    "application/json",
    "application/xml"
    ],
    "consumes": [
    "application/json",
    "application/xml"
    ],
    "apis": [
    {
    "path": "/resources/users.{format}",
    "description": ""
    }
    ]
    }`

    Also in the link ( http://restler3.luracast.com/annotations.html ) I found this sample code / annotations
    @class AccessControl {@requires user} {@level 5}

    What is the usage of level ?

    Arul
    @Arul-
    let me answer the last question first, requires and level are public properties of AccessControl, they can be static as well

    which is equal to calling

    AccessControl::$requires = ‘user’;
    AccessControl::$level = 5;

    It just depends on what your own class supports!

    Anas Anjaria
    @anasanjaria

    @Arul- is it possible that I can alter response generated by validation class ... say email is not valid then it gives me something like this

    { "error": { "code": 400, "message": "Bad Request: Invalid value specified foremail. Expecting email inname@example.comformat" }, "debug": { "source": "Validator.php:455 at validate stage", "stages": { "success": [ "get", "route", "negotiate" ], "failure": [ "validate", "message" ] } } }

    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.