Best Cosmetic Hospitals Near You

Compare top cosmetic hospitals, aesthetic clinics & beauty treatments by city.

Trusted • Verified • Best-in-Class Care

Explore Best Hospitals

Step-by-Step Guide to Fix PHP 8.2 & Missing Extensions Error

Below is a Complete Guide to fix your PHP 8.2 missing error (Unable to locate package) and properly install PHP 8.2, required extensions, and Composer for your Laravel project on Ubuntu/Linux Server. This will also help you avoid the “mbstring extension is missing” error in Composer.


Error:

root@ip-111-20-60-60:/opt/lampp/htdocs# sudo apt install php8.2-cli php8.2-mbstring php8.2-xml
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: Unable to locate package php8.2-cli
E: Couldn't find any package by glob 'php8.2-cli'
E: Unable to locate package php8.2-mbstring
E: Couldn't find any package by glob 'php8.2-mbstring'
E: Unable to locate package php8.2-xml
E: Couldn't find any package by glob 'php8.2-xml'

✅ Step-by-Step Guide to Fix PHP 8.2 & Missing Extensions Error


⚠️ Why This Error Happens

Ubuntu’s default package repositories often do not include PHP 8.2, especially on older versions of Ubuntu (20.04, 22.04). To get PHP 8.2, you need to add a special PHP PPA (Personal Package Archive) maintained by Ondřej Surý, a trusted PHP package maintainer.


📖 Step 1 – Add the PHP PPA (Trusted Source)

Run the following commands to add the PPA that contains PHP 8.2 packages.

sudo apt update
sudo apt install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt update

📖 Step 2 – Install PHP 8.2 and Required Extensions

Once the PPA is added, you can install PHP 8.2 and all the necessary extensions.

sudo apt install php8.2-cli php8.2-mbstring php8.2-xml php8.2-curl php8.2-zip unzip curl

Explanation

  • php8.2-cli – Command Line PHP (for running php commands)
  • php8.2-mbstring – Required by Laravel and Composer
  • php8.2-xml – Required for parsing XML files
  • php8.2-curl – Required for downloading packages
  • php8.2-zip – Required for extracting Laravel packages
  • unzip – Needed for Composer
  • curl – Needed to download Composer

📖 Step 3 – Verify PHP Installation

To confirm PHP 8.2 is installed, run:

php -v

You should see output like:

PHP 8.2.x (cli) (built: ...)

📖 Step 4 – Install Composer (Globally)

Download and install Composer (works with system PHP 8.2).

curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer
sudo chmod +x /usr/local/bin/composer

Verify Composer is working:

composer --version

You should see:

Composer version 2.x.x

📖 Step 5 – Use System PHP for Composer in Your Laravel Project

If your project is inside /opt/lampp/htdocs (XAMPP directory), you need to tell Composer to use system PHP (not XAMPP’s PHP).

To install Laravel dependencies:

cd /opt/lampp/htdocs/your-laravel-project
/usr/bin/php /usr/local/bin/composer install

This ensures system PHP 8.2 (with all extensions) is used instead of XAMPP’s PHP.


📖 Step 6 (Optional) – Make System PHP Default (If You Want)

If you want to make system PHP 8.2 the default PHP everywhere, you can change the $PATH in your user profile.

Edit your .bashrc file:

nano ~/.bashrc

Add this at the end:

export PATH=/usr/bin:$PATH

Save and reload:

source ~/.bashrc

This will ensure running php always uses system PHP 8.2, not XAMPP PHP.


🔔 Why This is Recommended

  • System PHP is better for CLI work (Composer, Artisan commands).
  • XAMPP PHP is often missing important extensions like mbstring, iconv, etc.
  • System PHP gets regular security updates via apt update.

Complete Command Summary

# 1. Update system and add PHP PPA
sudo apt update
sudo apt install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt update

# 2. Install PHP 8.2 and required extensions
sudo apt install php8.2-cli php8.2-mbstring php8.2-xml php8.2-curl php8.2-zip unzip curl

# 3. Verify PHP
php -v

# 4. Install Composer globally
curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer
sudo chmod +x /usr/local/bin/composer

# 5. Check Composer
composer --version

# 6. Run Composer in Laravel project using system PHP
cd /opt/lampp/htdocs/your-laravel-project
/usr/bin/php /usr/local/bin/composer install

🚀 You’re Ready to Use Laravel!

Best Cardiac Hospitals Near You

Discover top heart hospitals, cardiology centers & cardiac care services by city.

Advanced Heart Care • Trusted Hospitals • Expert Teams

View Best Hospitals
<p data-start="140" data-end="435">I’m Abhishek, a DevOps, SRE, DevSecOps, and Cloud expert with a passion for sharing knowledge and real-world experiences. I’ve had the opportunity to work with <a class="decorated-link" href="https://www.cotocus.com/" target="_new" rel="noopener" data-start="300" data-end="335">Cotocus</a> and continue to contribute to multiple platforms where I share insights across different domains:</p> <ul data-start="437" data-end="922"> <li data-start="437" data-end="514"> <p data-start="439" data-end="514"><a class="decorated-link" href="https://www.devopsschool.com/" target="_new" rel="noopener" data-start="439" data-end="485">DevOps School</a> – Tech blogs and tutorials</p> </li> <li data-start="515" data-end="599"> <p data-start="517" data-end="599"><a class="decorated-link" href="https://www.holidaylandmark.com/" target="_new" rel="noopener" data-start="517" data-end="569">Holiday Landmark</a> – Travel stories and guides</p> </li> <li data-start="600" data-end="684"> <p data-start="602" data-end="684"><a class="decorated-link" href="https://www.stocksmantra.in/" target="_new" rel="noopener" data-start="602" data-end="647">Stocks Mantra</a> – Stock market strategies and tips</p> </li> <li data-start="685" data-end="764"> <p data-start="687" data-end="764"><a class="decorated-link" href="https://www.mymedicplus.com/" target="_new" rel="noopener" data-start="687" data-end="732">My Medic Plus</a> – Health and fitness guidance</p> </li> <li data-start="765" data-end="841"> <p data-start="767" data-end="841"><a class="decorated-link" href="https://www.truereviewnow.com/" target="_new" rel="noopener" data-start="767" data-end="814">TrueReviewNow</a> – Honest product reviews</p> </li> <li data-start="842" data-end="922"> <p data-start="844" data-end="922"><a class="decorated-link" href="https://www.wizbrand.com/" target="_new" rel="noopener" data-start="844" data-end="881">Wizbrand</a> – SEO and digital tools for businesses</p> </li> </ul> <p data-start="924" data-end="1021">I’m also exploring the fascinating world of <a class="decorated-link" href="https://www.quantumuting.com/" target="_new" rel="noopener" data-start="968" data-end="1018">Quantum Computing</a>.</p>

Related Posts

The Definitive Guide to Certified FinOps Professional: Skills, Tracks, and Career Impact

The shift toward cloud-native architectures has fundamentally changed how organizations manage their finances, moving from fixed capital expenses to variable operational spend. This guide focuses on the…

Read More

A Complete Guide to the Certified FinOps Manager Credential

Cloud infrastructure spending has grown significantly, creating an urgent demand for professionals who understand the intersection of engineering, finance, and business strategy. The Certified FinOps Manager credential,…

Read More

Certified FinOps Engineer: The Definitive Career Guide for Modern Cloud Professionals

The shift toward cloud-native infrastructure has transformed how organizations consume resources, moving from fixed capital expenses to variable operational costs. In this landscape, the Certified FinOps Engineer…

Read More

Certified FinOps Architect: A Step-by-Step Guide to Mastery and Career Growth

Introduction The Certified FinOps Architect designation represents the highest tier of technical leadership in the intersection of finance and cloud engineering. As organizations scale their cloud footprint,…

Read More

The Professional Path to Certified DataOps Manager (CDOM): Scaling Data Reliability and Operational Excellence

Introduction The role of data in modern enterprise environments has shifted from a backend storage concern to the primary engine of business value. As organizations struggle to…

Read More

The Complete Roadmap to Becoming a Certified MLOps Manager: Skills, Tracks, and Real-World Impact

Introduction The transition from traditional software development to machine learning requires a robust operational framework that ensures reliability and scalability. A Certified MLOps Manager plays a pivotal…

Read More
0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x