A brief discussion on the simple installation and use of composer

青灯夜游
Release: 2023-04-04 11:12:01
forward
3171 people have browsed it

This article brings you a brief discussion of the simple installation and use of composer. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.

Simple installation of composer under linux

wget https://getcomposer.org/installer  //下载一个脚本文件

php installer  //php执行下这个php脚本

mv composer.phar /usr/bin/composer   //下载的文件转移到执行目录

composer config -g repo.packagist composer https://packagist.laravel-china.org //解决下载慢,不要用https://packagist.phpcomposer.com

composer require overtrue/wechat:~4.0 -vvv   //例子
Copy after login

Use of composer tools

<?php
require_once(dirname(__FILE__)."/vendor/autoload.php");
use EasyWeChat\Factory;

$options = [ 
    &#39;app_id&#39;    => 'wx3cf0f39249eb0exxx',
    'secret'    => 'f1c242f4f28f735d4687abb469072xxx',
    'token'     => 'easywechat',
    'log' => [
        'level' => 'debug',
        'file'  => '/tmp/easywechat.log',
    ],  
    // ...
];

$app = Factory::officialAccount($options);

$server = $app->server;
$user = $app->user;

$server->push(function($message) use ($user) {
    $fromUser = $user->get($message['FromUserName']);

    return "{$fromUser->nickname} 您好!欢迎关注 overtrue!";
});

$server->serve()->send();
Copy after login

The above is the detailed content of A brief discussion on the simple installation and use of composer. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:cnblogs.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!