phithon
5.05D
V2EX  ›  PHP

我自己写的类想用 composer 的 autoload,怎么使?

  •  
  •   phithon · Dec 1, 2015 · 3915 views
    This topic created in 3841 days ago, the information mentioned may be changed or developed.
    RT ,我试过在./vender/composer/autoload_psr4.php 里将自己写的类的 namespace 和文件路径对应上,可以。
    但过两天就消失了,应该是安装新的模块的时候 autoload_psr4.php 文件被重写了。。
    有没有持久的方法呢?

    ……深深感受到从一个黑客变成一个开发的难度……>.<,问题比较白痴见谅
    5 replies    2017-07-05 00:58:41 +08:00
    haiyang416
        1
    haiyang416  
       Dec 1, 2015 via Android   ❤️ 1
    修改 composer.json 的 autoload 部分。
    Scholer
        3
    Scholer  
       Dec 1, 2015
    还好看了下博客确实是搞安全的 不然就要开喷了 😂
    thenbsp
        4
    thenbsp  
       Dec 6, 2015 via Android
    不要修改 autoload_psr4.php ,这个文件在每次 composer repuire/install/update 时都会重写生成,你只需在你的 package 中的 compoaer.json 中添加 autoload 段,参考我的包:

    https://github.com/thenbsp/wechat/blob/master/composer.json
    hoythan
        5
    hoythan  
       Jul 5, 2017
    @thenbsp 对于没有发布到线上的自己的包应该放在那里呀?
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3235 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 113ms · UTC 12:00 · PVG 20:00 · LAX 05:00 · JFK 08:00
    ♥ Do have faith in what you're doing.