Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Arul
    @Arul-
    @anasanjaria Remember Laravel/Database has only the minimal stuff required to make Eloquent work the same way it does inside laravel. To keep it thin other parts of laravel are left out. Use iCache and create your own class that implements it instead
    Anas Anjaria
    @anasanjaria

    @Arul- I have created a class Users under app/con troller with one method protected

    ``/**

     * @access protected
     * @class AccessControl {@requires user}
     */
    function index()
    {
        return User::all();
    }``

    and add authentication class AccessControl ( the one used in examples ).

    error_log gives the following message

    PHP Notice: Undefined index: AccessControl in /path/to/my/project/../vendor/restler/framework/Luracast/Restler/Restler.php on line 667, referer: http://api.laravel.com/explorer/

    I tired to place AccessControl.php class under app/controller or under public folder where we have index.php .. but its still not working ..

    am I doing anything wrong ?

    Arul
    @Arul-
    try running php artisan dump-autoload
    Anas Anjaria
    @anasanjaria
    i tried but didnt work for me
    also we have autoload controllers via psr-0
    so i dun think dump-autoload will be necessary
    Arul
    @Arul-
    does your classes have any namespace?
    Anas Anjaria
    @anasanjaria
    no
    I have put my Authetication class i.e AccessControl under app/controller
    Arul
    @Arul-
    thats fine
    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