phithon
5.05D
V2EX  ›  PHP

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

  •  
  •   phithon · Dec 1, 2015 · 4292 views
    This topic created in 4009 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
    haiyang416
    Dec 1, 2015 via Android❤️1
    1
    修改 composer.json 的 autoload 部分。
    Scholer
    Scholer
    Dec 1, 2015
    3
    还好看了下博客确实是搞安全的 不然就要开喷了 😂
    thenbsp
    thenbsp
    Dec 6, 2015 via Android
    4
    不要修改 autoload_psr4.php ,这个文件在每次 composer repuire/install/update 时都会重写生成,你只需在你的 package 中的 compoaer.json 中添加 autoload 段,参考我的包:

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