1-3: Ekosistem PHP
Objectives
- Mengenal ecosystem PHP secara keseluruhan
- Memahami tools dan framework yang tersedia
- Mengetahui kemana harus mencari resource
Overview Ekosistem PHP
📊 Memuat diagram…
1. PHP Frameworks
Laravel — The King
┌─────────────────────────────────────────────────────────┐ │ LARAVEL — The PHP Framework for Web Artisans │ ├─────────────────────────────────────────────────────────┤ │ 🎯 Fokus: Rapid development, elegant syntax │ │ 📦 Ecosystem: Laravel Forge, Vapor, Envoyer, Nova │ │ 👥 Community: Huge, tutorial melimpah │ │ 📚 Learning: laracasts.com (premium, worth it) │ │ ⚡ Speed: Cukup cepat untuk most use cases │ │ ✅ Best for: Startup, MVP, medium-large apps │ ├─────────────────────────────────────────────────────────┤ │ Fitur Unggulan: │ │ • Eloquent ORM (database abstraction) │ │ • Blade templating │ │ • Artisan CLI │ │ • Laravel Mix / Vite │ │ • Built-in auth, validation, queue │ │ • Huge package ecosystem │ └─────────────────────────────────────────────────────────┘
Contoh Syntax Laravel:
php
// Routes
Route::get('/users', [UserController::class, 'index']);
// Controller
public function index() {
$users = User::where('active', true)->paginate(10);
return view('users.index', compact('users'));
}
// Model (Eloquent)
class User extends Model {
protected $fillable = ['name', 'email'];
}
Symfony — The Enterprise Choice
┌─────────────────────────────────────────────────────────┐ │ SYMFONY — The PHP Framework for Professionals │ ├─────────────────────────────────────────────────────────┤ │ 🎯 Fokus: Enterprise, reusable components │ │ 📦 Components: Banyak framework lain pakai ini │ │ 👥 Community: Strong, European-dominated │ │ 📚 Learning:Lebih steep dari Laravel │ │ ⚡ Speed: Sangat flexible, bisa dioptimize │ │ ✅ Best for: Large enterprise, complex systems │ ├─────────────────────────────────────────────────────────┤ │ Digunakan oleh: │ │ • Drupal (CMS) │ │ • Laravel (components) │ │ • eZ Platform (CMS) │ │ • PHPUnit (testing) │ └─────────────────────────────────────────────────────────┘
CodeIgniter — Lightweight Champion
┌─────────────────────────────────────────────────────────┐ │ CODEIGNITER — Simple and Powerful │ ├─────────────────────────────────────────────────────────┤ │ 🎯 Fokus: Simple, lightweight, fast │ │ 📦 Size: Very small footprint │ │ 👥 Community: Smaller but dedicated │ │ 📚 Learning: Easy untuk pemula │ │ ⚡ Speed: Sangat cepat, low resource │ │ ✅ Best for: Shared hosting, small-medium apps │ ├─────────────────────────────────────────────────────────┤ │ Kenapa pilih CodeIgniter? │ │ • Install mudah di shared hosting │ │ • Documentation clear │ │ • Tidak over-engineered │ │ • Good untuk belajar fundamentals │ └─────────────────────────────────────────────────────────┘
Perbandingan Framework
| Aspek | Laravel | Symfony | CodeIgniter | Slim |
|---|---|---|---|---|
| Learning curve | Medium | Steep | Easy | Easy |
| Size | Large | Large | Small | Tiny |
| Performance | Good | Excellent | Excellent | Excellent |
| Flexibility | Opinionated | Very flexible | Flexible | Minimal |
| Enterprise-ready | Yes | Yes | Moderate | No |
| Community size | Huge | Large | Medium | Medium |
| Package ecosystem | Huge | Large | Medium | Medium |
| Best for | General | Enterprise | Simple apps | APIs |
2. Content Management Systems (CMS)
WordPress — The Giant
┌─────────────────────────────────────────────────────────┐ │ WORDPRESS — 43% of the Web │ ├─────────────────────────────────────────────────────────┤ │ 📊 Market share: ~43% semua website │ │ 🎨 Themes: Ribuan themes gratis & premium │ │ 📱 Plugins: 60,000+ plugins di repository │ │ 👤 Users: Non-technical sampai enterprise │ │ 💰 CMS market: ~65% │ ├─────────────────────────────────────────────────────────┤ │ Technology Stack: │ │ • PHP 7.4+ (PHP 8.x recommended) │ │ • MySQL/MariaDB database │ │ • Vanilla JavaScript ( Gutenberg = React) │ │ • Template: PHP files dengan Loop │ └─────────────────────────────────────────────────────────┘
Contoh WordPress Loop:
php
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<h2><?php the_title(); ?></h2>
<div><?php the_content(); ?></div>
<?php endwhile; endif; ?>
3. Package Manager: Composer
┌─────────────────────────────────────────────────────────┐ │ COMPOSER — Dependency Manager for PHP │ ├─────────────────────────────────────────────────────────┤ │ 📦 Packagist: 350,000+ packages │ │ 🔗 Concept: Mirip npm untuk Node.js │ │ 📋 command: composer require vendor/package │ │ 🔄 Updates: composer update │ │ 🎯 Autoload: PSR-4 autoloading │ └─────────────────────────────────────────────────────────┘
Install Composer:
bash
# Linux/macOS
curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer
# Windows
# Download composer-setup.exe dari getcomposer.org
Contoh Penggunaan:
bash
# Install package
composer require ramsey/uuid
# Install development package
composer require --dev phpunit/phpunit
# Install semua dependencies dari composer.json
composer install
# Update semua packages
composer update
4. Tools & Utilities
Development Tools
🔍 Debugging:
- Xdebug — PHP debugger dengan step-by-step
- var_dump, dd() — Laravel debug
📊 Static Analysis:
- PHPStan — static analysis, catches bugs
- Psalm — type checking, mirip TypeScript
✨ Code Quality:
- PHP-CS-Fixer — auto-format code
- PHP_CodeSniffer — linting & formatting
- Pint — opinionated formatter (Laravel)
🧪 Testing:
- PHPUnit — unit testing framework
- Pest — elegant PHP testing
- Behat — BDD testing framework
📚 Documentation:
- phpDocumentor — generate API docs
- Swagger/PHPDoc — API documentation
VS Code Extensions untuk PHP
| # | Extension | Fungsi |
|---|---|---|
| 1 | PHP Intelephense | Intellisense, autocomplete |
| 2 | PHP Debug | Xdebug integration |
| 3 | PHP Namespace Resolver | Auto-import namespace |
| 4 | PHP Getters & Setters | Generate getters/setters |
| 5 | Laravel Blade Snippets | Blade syntax support |
| 6 | DotENV | .env file support |
5. Database Drivers
MySQL/MariaDB:
mysqli_*(native PHP driver)PDO_MySQL(unified interface)- Eloquent (Laravel ORM)
PostgreSQL:
pdo_pgsql- Eloquent (via package)
SQLite:
pdo_sqlite- Cocok untuk: dev, small apps, testing
MongoDB:
mongodb/mongodb(official driver)
6. Learning Resources
📖 Official:
- php.net/manual — Dokumentasi resmi
- phptherightway.com — Best practices
🎥 Video:
- Laracasts — Laravel & PHP (premium, worth it)
- Traversy Media — YouTube (gratis)
- Programmer Zaman Now — YouTube (Indonesian)
📝 Written:
- Medium — banyak PHP articles
- Dev.to — PHP community
- Reddit r/PHP
🇮🇩 Indonesian:
- Codepolitan — Courses & tutorials
- Petani Kode — Blog tutorial
- Warung Belajar — Laravel tutorials
PHP Framework Popularity (2024)
| Framework | ⭐ GitHub Stars | Popularitas |
|---|---|---|
| Laravel | 75K+ | ████████████████████████████ |
| Symfony | 30K+ | ████████████████████ |
| CodeIgniter | 20K+ | █████████████ |
| Slim | 12K+ | ████████ |
| CakePHP | 9K+ | ███████ |
| Yii2 | 14K+ | ███████ |
Exercise
- Install Composer di komputer kamu
- Browse packagist.org dan lihat package PHP yang popular
- Install VS Code extension "PHP Intelephense"
- Baca phptherightway.com dan highlight 3 hal baru yang kamu pelajari
Summary
| Kategori | Tools |
|---|---|
| Framework | Laravel, Symfony, CodeIgniter |
| CMS | WordPress, Drupal, Magento |
| Package Manager | Composer + Packagist |
| Debugging | Xdebug, var_dump |
| Static Analysis | PHPStan, Psalm |
| Code Quality | PHP-CS-Fixer, Pint |
| Testing | PHPUnit, Pest |
| Database | MySQL, PostgreSQL, SQLite, MongoDB |
Tip
Mulai dengan PHP vanilla untuk memahami fundamental. Setelah paham dasar-dasarnya, pilih Laravel untuk project nyata karena ecosystem-nya paling lengkap dan dokumentasinya melimpah.
Klik tombol ini setelah menyelesaikan materi
Quiz Bab 1
Uji pemahamanmu tentang Kenapa PHP?