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

Bridging Dev and Ops With Consulting Best Practices

Introduction Picture a mid-sized software engineering organization. The development team has spent the last three months building a new customer-facing analytics service. The code is polished, the…

Read More

Discovering Your Community: The Everyday Guide to Sourcing Nearby Goods and Services

Households constantly look for merchandise and professional assistance right in their immediate districts. While global shipping networks frequently command widespread attention, countless individuals still appreciate the instant…

Read More

Finding Clarity in Cancer Care: A Practical Guide for Patients and Families

Receiving a malignant diagnosis instantly disrupts a family’s normal rhythm, bringing immense emotional pressure right alongside urgent healthcare choices. Because contemporary oncology depends heavily on specialized clinical…

Read More

Choosing the Right Care Center: A Practical Approach to Neurosurgical Treatment and Hospital Selection

Facing a medical condition or a recommended treatment involving the brain, spine, or central nervous system can be a profound turning point. Because procedures targeting delicate neural…

Read More

The Kitchen Table Archive: Recovering Family Recipes and Culinary Roots

Cooking has always served as an unspoken chronicle of human life. Every meal carries an invisible narrative, linking us to previous eras through familiar aromas and grounding…

Read More

How DevOps Consulting Enhances Customer Experience

A customer adds items to a shopping cart, proceeds to checkout, and clicks submit. The screen freezes, spins for twenty seconds, and returns a blank page 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