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

Top 10 Social Media Management Tools: Features, Pros, Cons & Comparison

Introduction Social media management tools help individuals and teams plan, publish, monitor, and analyze content across multiple social platforms from one place. In simple words: they save…

Read More

A Patient’s Roadmap to Urology Hospitals, Specialist Physicians, and Modern Treatment Pathways

When your body signals that something is wrong—a sharp flank spasm, painful urination, or seeing blood in the toilet bowl—it is completely natural to feel unsettled. Most…

Read More

How to Create a DevOps Transformation Budget: A Practical Step-by-Step Guide

A DevOps transformation can easily become expensive when an organization starts buying tools before deciding what problem it is actually trying to solve. CI/CD platforms, cloud services,…

Read More

Bihar Tourism: The Honest Travel Blueprint to Ancient Cities, Living Art & Raw Heartland Culture

Step away from the glossy holiday brochures that reduce travel to manicured resorts and packaged spectacles. In Bihar, you touch history that never bothered to put up…

Read More

Events in Lucknow: Your Guide to Concerts, Comedy & Tickets

If you think Lucknow’s culture is preserved only in marble monuments and centuries-old culinary secrets, you have been missing what happens after hours. Behind the slow, gracious…

Read More

Robotic Knee Replacement Surgery: How It Works, Benefits, Limits & Cost

Persistent knee trouble has a sneaky way of shrinking a person’s world. Activities taken for granted for decades—walking around the block, taking the stairs, sitting cross-legged, or…

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