Thank you for your honest feedback. I get that you’re frustrated and want clear, real-world, working steps without gaps or “hand-waving.” Let’s do this with precision—I’ll spell out every single step, nothing skipped, nothing assumed. You’ll go from fresh XAMPP install to 2 Laravel microservices with internal (localhost) API communication and public access via domain.
🚩 Ultimate Step-by-Step: XAMPP + 2 Laravel Microservices (Localhost Internal, Domain Public)
✅ Assumptions
- You have XAMPP running (Linux/Mac:
/opt/lampp/htdocs
).
- Laravel 9+ installed for each MS (
mhn-hospital-ms
, mhn-doctors-ms
).
- Your system is not using Docker, and you want localhost API-to-API calls in dev, domain in prod.
A. Directory Setup
/opt/lampp/htdocs/myhospitalnow/mhn-hospital-ms
/opt/lampp/htdocs/myhospitalnow/mhn-doctors-ms
Each has its own public
, routes
, vendor
, etc.
B. Apache VHost & Alias Setup
1. Edit /opt/lampp/etc/extra/httpd-vhosts.conf
(or httpd.conf
if not using vhosts).
Add for both services:
<VirtualHost *:80>
ServerName localhost
DocumentRoot "/opt/lampp/htdocs"
Alias /hospitals /opt/lampp/htdocs/myhospitalnow/mhn-hospital-ms/public
<Directory "/opt/lampp/htdocs/myhospitalnow/mhn-hospital-ms/public">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
Alias /doctors /opt/lampp/htdocs/myhospitalnow/mhn-doctors-ms/public
<Directory "/opt/lampp/htdocs/myhospitalnow/mhn-doctors-ms/public">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
2. Save and close the file.
C. Enable mod_rewrite
Edit /opt/lampp/etc/httpd.conf
and ensure:
LoadModule rewrite_module modules/mod_rewrite.so
is not commented out.
D. .htaccess for Laravel
In each MS’s /public/.htaccess
:
<IfModule mod_rewrite.c>
RewriteEngine On
# Laravel routing
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
DO NOT add any www/https/redirects in development here!
E. Restart Apache
sudo /opt/lampp/lampp restart
F. Test Static Routes
In browser or terminal:
curl -I http://localhost/hospitals/
curl -I http://localhost/doctors/
Should show 200 OK
.
G. Set Up Internal API Env Variables
For doctors-ms needing hospital API:
In /opt/lampp/htdocs/myhospitalnow/mhn-doctors-ms/.env
add:
HOSPITAL_API_INTERNAL_URL=http://localhost/hospitals
In /opt/lampp/htdocs/myhospitalnow/mhn-hospital-ms/.env
add:
DOCTORS_API_INTERNAL_URL=http://localhost/doctors
H. Use Internal URL in Service Code
For example, in doctors-ms:
// Controller or Service file
$baseUrl = env('HOSPITAL_API_INTERNAL_URL');
$response = Http::post("$baseUrl/oauth/token", [
'grant_type' => 'client_credentials',
'client_id' => 29,
'client_secret' => 'SECRET',
]);
Never use APP_URL
for microservice-to-microservice calls!
I. Confirm API Route Exists
In hospital-ms, check routes/api.php
:
Route::post('/oauth/token', [YourController::class, 'token']);
Run:
php artisan route:list | grep oauth
If missing, add it.
J. Test CURL API Call
curl -X POST "http://localhost/hospitals/oauth/token" \
-H "Content-Type: application/json" \
-d '{"grant_type":"client_credentials","client_id":29,"client_secret":"SECRET"}'
Should get a token JSON. If 404/405: Fix the route or controller.
K. Use Domain Publicly
- For production, keep domain-based URLs in
.env
for user-facing/public requests.
- Don’t change APP_URL in dev every time; use the internal API variable for API calls.
Summary Table
| Service | Local Alias for Internal | Public (Domain) URL |
| ----------- | -------------------------------------------------------- | ---------------------------------------------------------------------------------- |
| hospital-ms | http://localhost/hospitals | https://www.myhospitalnow.com/hospitals |
| doctors-ms | http://localhost/doctors | https://www.myhospitalnow.com/doctors |
That’s Every Step — If Any Step Fails, Tell Me Where, What Command, and What Output. I’ll Debug with You!
If you want to try again, do exactly this. If it fails, show the error right after the failed step.
I’ll help you with the exact fix, no generic answers.
Let’s make it work, together. If you want a sample GitHub repo, let me know.
Your frustration is valid—let’s solve it for real.