无Composer安装Laravel扩展包咨询(含Laravel Page Speed)
Hey there! Let's break down your two scenarios for installing the Laravel Page Speed extension (or any Laravel package) on your live site, especially since you're using Filezilla for FTP. I’ve been in this exact situation before, so here’s what actually works:
Manual installation is doable, but it requires careful file handling and configuration since you’re bypassing Composer’s dependency management. Here’s the step-by-step:
- First, set up the extension locally on your computer:
- Either create a temporary Laravel project matching your server’s Laravel/PHP version, then run
composer require renatomarinho/laravel-page-speedto pull the package and its dependencies. - Or download the latest release archive from the package’s GitHub repo, but note this might miss required sub-dependencies.
- Either create a temporary Laravel project matching your server’s Laravel/PHP version, then run
- Use Filezilla to upload the necessary files to your server:
- Upload the entire
vendor/renatomarinho/laravel-page-speedfolder from your local project to the same path on your server (your site’s rootvendordirectory). - If you ran
composer requirelocally, you’ll also need to upload any new dependency folders added tovendor(check your localcomposer.lockto see what else was installed). - Upload the generated
config/pagespeed.phpfile (from your localconfigfolder) to your server’sconfigdirectory.
- Upload the entire
- Manually update Laravel’s configuration:
- Open your server’s
config/app.phpfile via Filezilla. - Add the service provider to the
providersarray:RenatoMarinho\LaravelPageSpeed\ServiceProvider::class, - If you want to use the facade, add this to the
aliasesarray:'PageSpeed' => RenatoMarinho\LaravelPageSpeed\Facades\PageSpeed::class,
- Open your server’s
- Clear Laravel’s cache (critical!):
- If your host provides a way to run PHP commands (like cPanel’s Terminal or a task runner), execute:
php artisan config:cache php artisan cache:clear - If not, manually delete all files in your server’s
bootstrap/cachedirectory via Filezilla.
- If your host provides a way to run PHP commands (like cPanel’s Terminal or a task runner), execute:
⚠️ Heads up: Manual installation risks missing hidden dependencies or version mismatches. Always test locally first before uploading to production.
Composer is the safest way because it automatically manages dependencies and version compatibility. Here are two ways to do this based on your server’s capabilities:
情况A:服务器支持SSH连接(首选方法)
Most decent hosting providers offer SSH access—this is the easiest route:
- Use an SSH client (like PuTTY, Xshell, or your local terminal) to connect to your server, then navigate to your Laravel project’s root directory.
- If Composer isn’t installed on your server, run these commands first to set it up:
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" php composer-setup.php php -r "unlink('composer-setup.php');" - Install the extension with Composer:
# If you have Composer globally installed composer require renatomarinho/laravel-page-speed # If you installed the phar file above php composer.phar require renatomarinho/laravel-page-speed - Publish the package’s configuration file (optional but recommended):
php artisan vendor:publish --provider="RenatoMarinho\LaravelPageSpeed\ServiceProvider" - Clear cache to apply changes:
php artisan config:cache
情况B:服务器仅支持FTP(your current setup)
If SSH isn’t an option, you can use your local Composer and upload the updated files:
- On your local computer, create a Laravel project that matches your server’s exact Laravel version and PHP version (this avoids compatibility issues).
- Run
composer require renatomarinho/laravel-page-speedlocally to install the package and all dependencies. - Use Filezilla to upload the updated
vendorfolder to your server. To be safe:- First, download a backup of your server’s existing
vendorfolder (in case something breaks). - Upload your local
vendorfolder, overwriting the server’s version. Alternatively, only upload the new folders added by the extension (check your localvendorfor new entries).
- First, download a backup of your server’s existing
- Upload the generated
config/pagespeed.phpfile to your server’sconfigdirectory (if you ranvendor:publishlocally). - Clear the cache as described in the manual installation section (either via command line if possible, or delete
bootstrap/cachefiles).
As for your earlier issue with CMD’s FTP command—don’t worry about that! Filezilla is way more user-friendly for FTP transfers, so stick with it.
内容的提问来源于stack exchange,提问作者jerome

