localhost/app
http://localhost/app
The localhost/app path is commonly used for web application development, serving as the root directory for full-stack applications, single-page apps (SPAs), and custom web projects during local development.
Application Directory Structure
htdocs/app/
├── public/ # Public web root
│ ├── index.php
│ ├── css/
│ ├── js/
│ └── images/
├── src/ # Application source code
│ ├── controllers/
│ ├── models/
│ ├── views/
│ └── config/
├── vendor/ # Composer dependencies
├── node_modules/ # NPM dependencies
├── composer.json
├── package.json
└── .htaccess
Create Basic PHP Application
<?php
// app/public/index.php
session_start();
// Simple routing
$request = $_SERVER['REQUEST_URI'];
$request = str_replace('/app', '', $request);
switch ($request) {
case '/':
require __DIR__ . '/../src/views/home.php';
break;
case '/about':
require __DIR__ . '/../src/views/about.php';
break;
case '/contact':
require __DIR__ . '/../src/views/contact.php';
break;
default:
http_response_code(404);
require __DIR__ . '/../src/views/404.php';
break;
}
?>
MVC Application Structure
// src/controllers/UserController.php
class UserController {
private $userModel;
public function __construct() {
require_once __DIR__ . '/../models/User.php';
$this->userModel = new User();
}
public function index() {
$users = $this->userModel->getAll();
require __DIR__ . '/../views/users/index.php';
}
public function show($id) {
$user = $this->userModel->find($id);
require __DIR__ . '/../views/users/show.php';
}
}
// src/models/User.php
class User {
private $db;
public function __construct() {
$this->db = new PDO('mysql:host=localhost;dbname=myapp', 'root', '');
}
public function getAll() {
$stmt = $this->db->query('SELECT * FROM users');
return $stmt->fetchAll(PDO::FETCH_ASSOC);
}
public function find($id) {
$stmt = $this->db->prepare('SELECT * FROM users WHERE id = ?');
$stmt->execute([$id]);
return $stmt->fetch(PDO::FETCH_ASSOC);
}
}
// src/views/users/index.php
Users
All Users
-
<?php foreach ($users as $user): ?>
- <?php echo htmlspecialchars($user['name']); ?> <?php endforeach; ?>
React Single Page Application
# Create React app in app directory
cd C:\xampp\htdocs
npx create-react-app app
# Start development server
cd app
npm start
# Builds to: http://localhost:3000
# For production: npm run build
# Deploy build/ folder to htdocs/app/
# Access production build at: http://localhost/app
Fix "localhost/app Not Found"
Create App Directory
# Windows XAMPP
cd C:\xampp\htdocs
mkdir app
cd app
echo "<?php phpinfo(); ?>" > index.php
# Linux
cd /var/www/html
sudo mkdir app
sudo nano app/index.php
# Set permissions
sudo chown -R www-data:www-data app
sudo chmod -R 755 app
Laravel Application Setup
# Install Laravel in app directory
cd C:\xampp\htdocs
composer create-project laravel/laravel app
# Start development server
cd app
php artisan serve
# Access at: http://localhost:8000
# Or configure virtual host for http://localhost/app
Organization Tip:
Use the /app directory as your main application folder. Keep public assets in public/, source code in src/, and configuration in config/ for better organization and security.
Frequently Asked Questions
What is localhost/app used for?
It's a common path for web application development, serving as the root directory for your application code, assets, and configuration during local development.
How do I access my app at localhost/app?
Create an "app" folder in htdocs (XAMPP) or www (WAMP), add an index.php or index.html file, ensure Apache is running, then visit http://localhost/app in your browser.
Can I run multiple apps on localhost?
Yes, create separate folders like /app1, /app2, or use virtual hosts to assign different domains like app1.local, app2.local pointing to different directories.
Related URLs and Resources
- localhost/api - API endpoints
- localhost/admin - Admin panel
- localhost/dev - Development path
- localhost/demo - Demo applications