Laravel,如何在没有作曲家的情况下手动安装包

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/45566233/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 16:28:17  来源:igfitidea点击:

Laravel, how to manually install package without composer

phplaravelcomposer-phpfilezilla

提问by begineeeerrrr

Wanted to install Laravel-Excel (Maatwebsite) package manually without composer, but I dont know how.

想在没有作曲家的情况下手动安装 Laravel-Excel (Maatwebsite) 包,但我不知道如何。

Why? Because I have a laravel project in a free hosting server setup by other guy, and I can only access using Filezilla to edit/download/upload the codes.

为什么?因为我在其他人设置的免费托管服务器中有一个 laravel 项目,我只能使用 Filezilla 访问来编辑/下载/上传代码。

If only Filezilla allow a command prompt that could use "composer update", then it will be easier.

如果只有 Filezilla 允许可以使用“composer update”的命令提示符,那么它会更容易。

回答by user3369343

  1. Add the package to the vendor folder. You can upload it using filezilla
  2. Add a reference in \vendor\composer\autoload_namespaces.php
  3. Add a reference in \vendor\composer\autoload_psr4.php
  1. 将包添加到供应商文件夹。您可以使用 filezilla 上传它
  2. 在 \vendor\composer\autoload_namespaces.php 中添加一个引用
  3. 在\vendor\composer\autoload_psr4.php 中添加引用

Source laravel.io

来源laravel.io

回答by Quockhanh Pham

I got solution! I cant use composer on my company because of secure network. But i can download zip form github and install it manual. The below is my example for HTMLPurifier:

我得到了解决方案!由于网络安全,我无法在我的公司使用 Composer。但我可以从 github 下载 zip 格式并手动安装。下面是我的HTMLPurifier示例:

  1. download and extract library mews/purifier to vendor directory https://github.com/mewebstudio/Purifier
  2. add below line in vendor/composer/autoload_psr4.php
  1. 下载并解压库 mews/purifier 到供应商目录https://github.com/mewebstudio/Purifier
  2. vendor/composer/autoload_psr4.php 中添加以下行

This sentence will load all of file from vendor/mews/purifier/src and autoload in namespace Mews\Purifier\

这句话将从 vendor/mews/purifier/src 加载所有文件并自动加载到命名空间 Mews\Purifier\

'Mews\Purifier\' => array($vendorDir . '/mews/purifier/src'),

Sometime you need add library into autoload_namespaces.phpintead of, please read in https://getcomposer.org/doc/04-schema.md#autoload

有时您需要将库添加到autoload_namespaces.php中,请阅读 https://getcomposer.org/doc/04-schema.md#autoload

You got Mews\Purifier\Facades\Purifier not found if public config before finish step 3

如果在完成第 3 步之前没有找到公共配置,你会得到 Mews\Purifier\Facades\Purifier

$ php artisan vendor:publish --provider="Mews\Purifier\PurifierServiceProvider"

$ php artisan vendor:publish --provider="Mews\Purifier\PurifierServiceProvider"

  1. add below json in vendor/composer/installed.json
  1. vendor/composer/installed.json 中添加以下 json

This for composer history, providersand aliaseswill be load in config/app/php for register new provider

这对于作曲家历史,提供者别名将加载在 config/app/php 中以注册新的提供者

{
    "name": "mews/purifier",
    "version": "v2.0.12",
    "type": "library",
    "extra": {
        "laravel": {
            "providers": [
                "Mews\Purifier\PurifierServiceProvider"
            ],
            "aliases": {
                "Purifier": "Mews\Purifier\Facades\Purifier"
            }
        }
    },
    "autoload": {
        "psr-4": {
            "Mews\Purifier\": "src/"
        }
    }
},

Now you run this config, then vendor/mews/purifier/config will be move to config folder

现在你运行这个配置,然后 vendor/mews/purifier/config 将被移动到 config 文件夹

$ php artisan vendor:publish --provider="Mews\Purifier\PurifierServiceProvider"

$ php artisan vendor:publish --provider="Mews\Purifier\PurifierServiceProvider"

回答by Ali

download the package locally and then upload the package folder (found under vendor) along with the updated composer.json

在本地下载包,然后上传包文件夹(在供应商下找到)以及更新的 composer.json

回答by connormcwood

Depending on how strict the server is, you could SSH into your Server. But doing it locally then uploading the required files is usually the way to go.

根据服务器的严格程度,您可以通过 SSH 连接到您的服务器。但是在本地做然后上传所需的文件通常是要走的路。

You might need to run composer autodump if you don't wipe the cache.

如果您不擦除缓存,您可能需要运行 composer autodump。

回答by waleedazam

it's easy to do it by following this download the package and set the files in app folder

按照这个下载包并在应用程序文件夹中设置文件很容易做到这一点

YourProject/app/Laravel-Excel/

and then add the path to composer.json in autoload

然后在自动加载中添加 composer.json 的路径

"autoload": {
    ...
    "classmap": [
        "database/seeds",
        "database/factories"
        "app/Laravel-Excel"
    ],
    ...
},

Run the composer dump-autoload

跑过 composer dump-autoload

the solution refs to this question referance answer

解决方案参考了这个问题参考 答案

回答by ren

upload \vendor\maatwebsite copy \vendor\maatwebsite\excel\src\config\excel.php to \config\excel.php

上传\vendor\maatwebsite copy \vendor\maatwebsite\excel\src\config\excel.php 到\config\excel.php