Courses

Laravel Web to Mobile API: Reuse Old Code with Services

  • 10 lessons
  • 14946 words

This content is available only for premium members.

About this course

Imagine a situation when you have a typical Laravel web project. One day, you're told that the company is building a mobile app, and now you need to create a Laravel API for it.

  • How do you build it on top of the existing project?
  • How not to duplicate the code?
  • How to avoid bugs in the web version while creating the API?
  • How to still keep both versions maintainable for the future?

These are pretty standard questions. And we will answer them with our practical example.

This is actually a "Part 2" follow-up course after Laravel Vue Inertia: Food Ordering Project Step-By-Step. At the end of that course, we had a web-based food ordering system:

In our case, it's Vue Inertia, but generally, it may be any Laravel project, even without Vue. And now, the goal is to create an API on top.

So, in this course, we will add more code to the same repository:

  • API Routes
  • Laravel Services to use in both web/API
  • Automated tests

This is overall a great exercise on refactoring code and making it maintainable for the future.

So, let's dive into the first lesson!