Modern web development often requires package managers like Composer for PHP and npm for Node.js. This guide explains how to use them on your hosting account.
Prerequisites
- SSH access must be enabled for your hosting account.
- Connect to your server via SSH before running any commands.
Composer (PHP Package Manager)
Composer manages PHP libraries and dependencies. Most modern PHP frameworks (Laravel, Symfony) and many WordPress plugins use Composer.
Checking if Composer is installed:
composer --version
Installing dependencies from composer.json:
cd /path/to/your/project
composer install
This reads composer.json and downloads all required packages to the vendor/ directory.
Adding a new package:
composer require vendor/package-name
Updating packages:
composer update
Note: On shared hosting, memory may be limited. If you encounter memory errors, try:
COMPOSER_MEMORY_LIMIT=-1 composer install
Alternatively, run composer install locally and upload the vendor/ directory via FTP.
Node.js and npm
Node.js runs JavaScript on the server. npm (Node Package Manager) manages JavaScript dependencies.
Checking if Node.js is installed:
node --version
npm --version
Installing project dependencies:
cd /path/to/your/project
npm install
This reads package.json and downloads packages to the node_modules/ directory.
Building a project:
npm run build
Many frontend frameworks (React, Vue, Next.js) require a build step to compile assets for production.
Running scripts:
npm run start
npm run dev
Common Workflows
Laravel Deployment:
cd /path/to/laravel
composer install --no-dev --optimize-autoloader
php artisan migrate --force
php artisan config:cache
php artisan route:cache
Next.js or React Deployment:
cd /path/to/project
npm install
npm run build
The built files (typically in a build/ or dist/ directory) should be placed in your public_html.
Tips
- Always use --no-dev flag with composer install in production to skip development dependencies.
- Keep package lock files (composer.lock, package-lock.json) in version control for reproducible builds.
- If your hosting plan has limited SSH execution time, consider building locally and uploading the compiled assets.
- Node.js applications that need to run persistently may require a VPS or dedicated server with a process manager like PM2.
Need Help?
If Composer or Node.js is not available on your hosting account, contact our support team. Availability depends on your hosting plan.