📲 Download Utility Tools Apps

EMI Calculator

Download EMI Calculator

SOA Games

Download SOA Games

SOA Technology App

Download SOA Technology

BMI Checker

Download BMI Checker

Task Jira

Download Task Jira

Laughing Adda

Download Laughing Adda

📅 हिंदी कैलेंडर ऐप डाउनलोड करें

Download Shubhcalendar App

hands-on practice exercises for Composer & Packages (PHP)

🧪 Composer Practice Exercises (PHP)

🟢 Level 1: Basics (Beginner)

✅ Exercise 1: Install Composer

  • Install Composer on your system
  • Run:
composer -v

👉 Output should show version


✅ Exercise 2: Create First Project

  • Create a new folder composer-practice
  • Run:
composer init
  • Fill details (name, description, etc.)

👉 Check: composer.json created


✅ Exercise 3: Install First Package

Install a simple package:

composer require monolog/monolog

👉 Task:

  • Open composer.json
  • Verify package added
  • Check vendor/ folder

🟡 Level 2: Usage (Intermediate)

✅ Exercise 4: Use Installed Package

👉 Create index.php

<?php
require 'vendor/autoload.php';use Monolog\Logger;
use Monolog\Handler\StreamHandler;$log = new Logger('app');
$log->pushHandler(new StreamHandler('app.log', Logger::WARNING));$log->warning('This is a warning!');
$log->error('This is an error!');

👉 Task:

  • Run file
  • Check app.log created

✅ Exercise 5: Install PHPMailer

composer require phpmailer/phpmailer

👉 Task:

  • Create a PHP script to send email
  • (Use dummy SMTP if needed)

✅ Exercise 6: Remove Package

composer remove monolog/monolog

👉 Task:

  • Check:
    • composer.json
    • vendor/

🟠 Level 3: Autoloading

✅ Exercise 7: Manual vs Autoload

👉 Without Composer:

  • Create 3 PHP class files
  • Include using require

👉 With Composer:

  • Use:
require 'vendor/autoload.php';

👉 Task:

  • Compare code length and readability

✅ Exercise 8: PSR-4 Autoload

👉 Step 1: Update composer.json

{
"autoload": {
"psr-4": {
"App\\": "src/"
}
}
}

👉 Step 2:

composer dump-autoload

👉 Step 3: Create class

📁 src/User.php

<?php
namespace App;class User {
public function sayHello() {
return "Hello User!";
}
}

👉 Step 4: Use it

<?php
require 'vendor/autoload.php';use App\User;$user = new User();
echo $user->sayHello();

🔴 Level 4: Real-World Practice

✅ Exercise 9: Build Logger System

👉 Task:

  • Use Monolog
  • Create logs for:
    • Login success
    • Login failure
    • Errors

✅ Exercise 10: API Integration

👉 Task:

  • Install:
composer require guzzlehttp/guzzle
  • Fetch data from:
https://jsonplaceholder.typicode.com/posts

👉 Display:

  • First 5 posts

✅ Exercise 11: Mini Project (Important)

👉 Build: Simple Contact Form System

Requirements:

  • Use PHPMailer (via Composer)
  • Form fields:
    • Name
    • Email
    • Message
  • Send email on submit

🧠 Bonus Challenges (Advanced)

🚀 Challenge 1:

Create your own PHP package and install it using Composer locally


🚀 Challenge 2:

  • Add version constraints in composer.json
  • Try:
"phpmailer/phpmailer": "^6.0"

👉 Test:

  • Run composer update

🚀 Challenge 3:

  • Delete vendor/
  • Run:
composer install

👉 Understand:

  • Difference between install vs update

🎯 Tip (For You)

  • 🧪 1 task per day


AI Spiritual Tools & Interactive Experiences

Explore powerful AI-driven tools for daily guidance, spirituality, fun quizzes, and self-discovery.

Today’s Quote

Get inspiring daily quotes powered by AI to motivate and guide your day.

Explore Now

AI Tarot Card Reader

Reveal insights about your future, love, and career with AI tarot readings.

Read Tarot

Love Match Calculator

Check compatibility and love predictions using AI-based analysis.

Check Match

Fortune Cookie

Open an AI fortune cookie and receive wisdom, luck, and fun messages.

Open Cookie

Quiz Categories

Engage with knowledge-based and fun quizzes across multiple categories.

Start Quiz

Panchang Calendar

View daily Panchang, auspicious timings, tithi, nakshatra, and festivals.

View Panchang

Online Numerology

Discover your destiny number, life path, and numerology predictions.

Calculate Now

Spiritual Feeds

Stay connected with spiritual thoughts, mantras, and divine content.

View Feeds

Quiz Hub

Attempt trending quizzes on GK, spirituality, festivals, and more.

Explore Quizzes