A native app cannot be updated at the same moment as the server. People keep old builds for months. If the API changes shape without a plan, those builds fail in ways that look like random bugs and are painful to reproduce.
We treat the API as a product with its own compatibility promise. Laravel is a strong place to keep that promise because routing, validation, auth, and queues are already structured. The discipline is in the contract, not in the framework logo.
Design the contract before the screens harden
Write the resources the app needs: the account, the list, the detail, the action. Name fields in language the app can keep. Decide what is required. Decide which fields may appear later without breaking older apps. Additive changes are cheap. Renames and type changes are not.
- Lists are paginated. Never return an unbounded collection to a phone.
- Errors use a stable code plus a human message the app can show.
- Dates are one format, in UTC, everywhere.
- Ids are strings in JSON if there is any chance they will outgrow an integer on the client.
Auth that survives a flaky network
Mobile networks drop mid-request. Tokens expire on a train. The client needs a clear 401 it can refresh, and a clear “you are signed out” it should not retry forever. Keep access tokens short-lived and refresh predictable. Do not bury a business rule inside an authentication error. “Your plan expired” is not the same as “your token expired.”
A release-safe API habit
- Version the contract when a change would break an app already in the store.
- Ship new fields before the app depends on them.
- Keep the old behavior until store metrics say the old app is gone, or until you have forced an upgrade on purpose.
- Log the app version on each request so you can see who still needs the old shape.
- Feature-flag risky behavior on the server so you can turn it off without a store review.
The oldest app still installed is part of your production environment.
Performance the phone can feel
A native client feels slow when the API is chatty or heavy. Prefer one well-shaped payload for a screen over five small calls that each wake the radio. Cache what rarely changes. Compress images on the server to the sizes the UI actually displays. Push slow work — PDF, import, notification fan-out — onto a queue and give the app a status to poll or a push when it finishes.
Index the queries behind the main screens and look at them with production-sized data, not a dozen seed rows. An endpoint that is fine in development and timing out for a real customer is a scaling problem you already had. You just had not met the data yet.
How the two teams stay in sync
The app and the API need a shared changelog. When a field is added, the app ticket links to it. When a field is deprecated, the date and the minimum app version are written down. Laravel’s tests should cover the contract the app depends on, including the error cases. A green test suite that never asserts the JSON shape will not save you.
When should we version?
Version when you must break an existing client. Do not version because a new screen needs a new endpoint. New routes can live beside old ones. Breaking the login response cannot.
Leave a Reply
Your email address will not be published. Required fields are marked *
More from the studio
Comments(00)
No comments yet. Be the first to join the conversation.