简体   繁体   中英

Is it possible to use the Laravel Eloquent ORM with an API

I am building an application which uses an API to get/save data rather than a MySQL database. The application is acting as an isolated front end.

I really like how the Laravel Eloquent ORM works but it seems to only work with the databases specified in the documentation.

Would it be possible to use Eloquent to interact with data on an API over HTTP/HTTPS?

No, it's not possible, mainly because each HTTP API has its own "format" so there's no easy way to create a tool that can be compatible with all existing APIs to provide a standard interface like Eloquent does.

What you can do however is create an extension that would interact with the API and provide the same methods that Eloquent does.

If you need libraries for consuming an API, you can try Guzzle or Httpful , both installable via Composer.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM