Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

erichbriceno's avatar

Two Api in laravel on the same server

I am developing a system that requires the implementation of several API type applications that communicate with each other. I have two instances of Laravel running on the same server. They are both simple APIs. App A is called Athena and App B is called Zeus. I need to consume from one api to the other, but an error occurs and I don't understand what the problem is.

on Zeus ItemController public function index() { $articles = Article::all(); return $articles; }

in Athena TestController public function index() { $variable = HTTP::get('http://zeus.local/api/articles'); $variableArray = $variable->json(); return $variable; }

And it generates the following error:

Illuminate\Database\QueryException SQLSTATE[42S02]: Base table or view not found: 1146 Table 'athena.articles' doesn't exist (SQL: select * from articles)

I don't understand why the Zeus app does a search as if the items table were part of the Athena app.

0 likes
1 reply
fylzero's avatar

@erichbriceno Your Zeus ItemController is calling Article::all(), so it is going to try to find that table based on the model pattern. You haven't said anything about how your database(s) are set up. If you have multiple databases on the same server you could just create connections for both apps and not have to use an API. This would likely be more efficient.

Please or to participate in this conversation.