Giter Site home page Giter Site logo

phalcon-rest's Issues

Example Model

Implement an example controller using Phalcon ORM models and the query builder.

Composer Support

I believe composer support + autoloading would be awesome for this.

JSON Responses need refactor

All the JSON response generation is done inline within the index file. This needs to be refactored out into a JSONResponse class.

Errors need JSON reconfiguring

Currently, all errors are returned as JSON, with an incorrect envelope implementation. Errors should respect the API conventions, too.

Why I can't connect to mysql?

Hi everyone, I've used Phalcon micro for a couple of months, and now I want to switch to something more RESTful, and I found this repo https://github.com/cmoore4/phalcon-rest

  1. I've declared database parameters in config.ini

    [database]
    adapter  = Mysql
    host     = localhost
    username = test
    password = test
    name     = test
  2. I've set the di to connect to db

    $di->set('db', function() use ($config) {
    $dbclass = 'Phalcon\Db\Adapter\Pdo\\' . $config->database->adapter;
    return new $dbclass(array(
        "host"     => $config->database->host,
        "username" => $config->database->username,
        "password" => $config->database->password,
        "dbname"   => $config->database->name
    ));
    });
  3. Class Princesses.php in is models folder

  4. When I tried to add this line

    $princesses = Princesses::find();
    in the ExampleController.php, I got the blank page when going to host/v1/example. When I removed that line, everything is fine.

What is the problem here?

Thank you very much. Any help is appreciated!

Tests

This needs tests.

return json in RESTControlloer

Hi,

Thanks, for the framework. It works great .

I would like to validate the user in the entry point ( RESTController ) .

I wrote a common method in RESTController, But the action continue executing
after return statement.

Can you suggest me how do I do ?

Raja K

Optional Envelope Parameter

The JSON envelope is arbitrary. While it makes the API more discoverable, it also violates strict REST principles.

Add an "envelope=false" query parameter that moves the _meta information into HTTP headers.

Error in Example

When I run this request:
http://api.phalconrest.local/v1/example
I get the error:
Fatal error: Using $this when not in object context in /var/www/phalcon-rest/controllers/ExampleController.php on line 29

I found that the problem is in index.php line 196, by replacing this:
->setHandler('\PhalconRest\Controllers\ExampleController');
with this:
->setHandler(new \PhalconRest\Controllers\ExampleController());

all works well.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.