Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Database and Middleware example #9

Open
codeezy opened this issue Jul 13, 2020 · 4 comments
Open

Database and Middleware example #9

codeezy opened this issue Jul 13, 2020 · 4 comments

Comments

@codeezy
Copy link

codeezy commented Jul 13, 2020

Thanks for your framework. I try to use this, but i have a couple of questions.

  1. Can you add some example for Slim Middleware integration?
  • JWT
  • Rate Limit
  1. Explain an example the correct way to mysql connect with illuminate/database
@gotzmann
Copy link
Owner

gotzmann commented Jul 13, 2020

I'll show examples of using Slim middleware and DB connection with Laravel little bit later on docs.

You have to add to your composer.json:

composer require illuminate/database

And use Eloquent somewhere on the app like this:

...
use Illuminate\Database\Capsule\Manager as ORM;
...
$orm = new ORM;
$orm->addConnection([
    'driver'    => getenv('DB_TYPE'),
    'host'      => getenv('DB_HOST'),
    'port'      => getenv('DB_PORT'),
    'database'  => getenv('DB_NAME'),
    'username'  => getenv('DB_USER'),
    'password'  => getenv('DB_PASSWORD'),
    'options'   => [ \PDO::ATTR_TIMEOUT => 5 ],
]);
$orm->setAsGlobal();
...
$rows = ORM::select("SELECT * FROM table");
...

@codeezy
Copy link
Author

codeezy commented Jul 13, 2020

Thank you, i will wait for your examples.
I should say that JWT & Rate Limit need to be included in base package, because these are main middleware for REST.
You have tested the Comet with Eloquent, how many rps we can expect?

@gotzmann
Copy link
Owner

Eloquent performance is only at 50% of the equivalent PDO queries with prepared statements. Not good but no so bad either. I suppose Eloquent with entity models will be even slower. I'm struggling to find performant and popular ORM framework in PHP so stick with Eloquent now.

@FelipoAntonoff
Copy link

Hi, I recommend the Idiorm, I have been using it for a few years, very simple and easy to use, but without the extra resources of Eloquent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants