I am fairly new to PHP (about 8 months). I am building a web app, which is almost ready for beta. I am only now starting to think about what I would need to do to make a mobile version of the app.
As I understand, I should be building a REST API (please correct me if I'm wrong). I am currently NOT using a PHP framework for my web app. Should I be?
Should I now begin using a framework so that I could more easily implement my API? Or can I build my API without any framework at all?
Create the Model/Database. php file with the following contents. This is a database access layer class, which allows us to set up a connection to the MySQL database. Apart from the connection setup, it contains generic methods like select and executeStatement that allow us to select records from a database.
Why use a PHP framework? A PHP framework provides a basic structure for streamlining the development of web apps. We use them because they speed up the development process. Above all, the responsiveness of websites and applications built using PHP frameworks helps businesses fulfill their performance needs.
The REST API is part of the integration framework and handles requests from external consumers. The following diagram provides an overview of how the REST API handles requests. When an external consumer initiates a request, a REST API controller directs the resource request to the appropriate resource handler.
PHP REST API: Lumen Lumen is a micro-API framework made out of Laravel. Specially designed for building REST APIs, this framework cuts off all Laravel features that restrict stateless APIs. Instead, it focuses on what is useful to REST APIs. This is why Lumen is such a lightweight framework.
SHORT ANSWER No, you don't need a framework to achieve your goal.
BUT it will be really easier if you use a framework to manage your API. I suggest you to go for a lightweight framework and maybe you can convert easily your webapp to the framework too, having one "app" to return two different "things" (web stuff & API).
Take a look at Laravel, Laravel 4 based REST API or a list of popular php rest api frameworks that can be used to build one.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With