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

isarantoglou's avatar

Help with creating an API for a legacy application

Hello,

I am going to do a project and I need some help with some questions. There is a legacy application (no framework, plain old php, no database conventions, spagheti code :) ). I will have to make an API for that application using laravel. My questions are:

  1. For the authentication I would choose a simple api-key schema. Each account will have an API-key to be authenticated. Do I need any package (like sanctum) or can I do with with just laravel gate?
  2. Will I have any problems with eloquent since there will be no migrations and database does not meet laravel conventions?

Thank you in advance.

0 likes
3 replies
jlrdw's avatar

The documentation explains how to override conventions when needed. But are you migrating to eloquent or planning on rewriting some queries in query builder.

However if you have working queries now, many can be used as is using the db facade or the PDO instance getPd0().

Using migrations though suggested is optional, especially if you have a current database.

NOTE read warnings if you use, someone recently lost all their data by not having a backup and running migrations on production.

Don't run on production, if you do Backup first.

Three main rules for using migrate:

  • Rule 1 Backup first
  • Rule 2 Backup first
  • Rule 3 Backup first
isarantoglou's avatar

@jlrdw Thank you for you answer.

The application has no API, the API will be build from scratch.The appication does have indeed have the CRUD funcionality for the things I will be building, so I can get that queries and use them and not use eloquent at all.

I will not use migration at all probably. Also I forgot about just using plain DB facace and run queries without using eloquent at all :)

Ill just now have to figure out how to make the authentication with an API Key (based from the header of the request).

Please or to participate in this conversation.