The backend for SyncUp, the chat app built in the NativePHP Masterclass. It's a standard Laravel app with Sanctum token authentication, and the mobile app talks to it over HTTP.
The mobile app itself lives in its own repository: NativePHP/syncup.
Sign up for the course: nativephp.com/course
Each commit holds the backend work from one video in the course, so you can jump to the state of the API at the end of any video. The backend first appears in the Authentication video.
| Commit message | Video |
|---|---|
Authentication |
Sanctum token auth: register, login, logout, and the current user |
| Method | Endpoint | Auth | Description |
|---|---|---|---|
POST |
/api/register |
None | Create an account and get a token |
POST |
/api/login |
None | Log in and get a token |
POST |
/api/logout |
Bearer token | Revoke the current token |
GET |
/api/user |
Bearer token | Get the logged-in user |
Send an Accept: application/json header with every request, so validation errors come back as JSON with a 422 status.
- PHP 8.3+
- Composer
git clone https://github.com/NativePHP/syncup-api.git
cd syncup-api
composer install
cp .env.example .env
php artisan key:generate
php artisan migrateThe app uses SQLite by default, so there's no database server to set up.
If you use Laravel Herd, park or link the folder and the API is available at http://syncup-api.test. That's the address the course uses, and it works from the iOS simulator because the simulator shares your Mac's network.
A real phone or the Android emulator can't reach .test addresses. For those, deploy the API somewhere like Laravel Cloud, or serve it on your local network:
php artisan serve --host=0.0.0.0 --port=8000Then use your computer's local IP address (for example http://192.168.1.20:8000) as the API's URL.
In the SyncUp app's .env, set API_BASE_URL to the API's address, including /api:
API_BASE_URL=http://syncup-api.test/api-
List the commits (oldest first) to find the one for that video:
git log --oneline --reverse
-
Check out that commit using its hash:
git checkout <commit-hash>
Git will say you're in a "detached HEAD" state. That's expected. You're viewing a snapshot, not a branch.
-
Reinstall dependencies and run any new migrations:
composer install php artisan migrate
-
When you're done, go back to the latest version:
git checkout main
To see exactly what a video changed, run git show <commit-hash>, or git show --stat <commit-hash> for just the list of files.
php artisan testSyncUp API is open-source software licensed under the MIT license.