[pkg-php-pear] usage of phpab when no autoload in composer.json
Robin Gustafsson
robin at rgson.se
Mon Feb 28 22:12:37 GMT 2022
Hi,
On Wed, Feb 23, 2022 at 9:41 AM Fab Stz <fabstz-it at yahoo.fr> wrote:
> I have a package (kalkun) that uses composer.json to load dependencies.
> However, in itself, the package has no classes to put in the
> spl_autoload_register of the autoload file (composer.json doesn't have an
> autoload section).
>
> Hence, I'm not able to run phpab on the template. It fails with this error:
>
> $ phpab --output autoload.php \
> --template debian/autoload.php.tpl \
> composer.json
> phpab %development% - Copyright (C) 2009 - 2022 by Arne Blankerts and
> Contributors
>
>
> Error while processing request:
> - No units were found - process aborted.
>
>
>
> How should I use phpab to have only the "require_once" statements at the
> begining and have nothing in spl_autoload_register ? I tried with the "-s"
> (static) option but it doesn't seem to be the correct result.
Indeed, this is an unsupported use-case. phpab only generates the
spl_autoload_register part, so there's no reason for it to have an
option to skip it. Meanwhile, phpabtpl, which generates the parts you
do want, was meant specifically for use with phpab and its usefulness
without phpab hasn't been considered before.
One suggestion would be to use phpabtpl to generate a template, but to
skip phpab altogether and instead just remove the
spl_autoload_register part from the template. It could be automated
with e.g. sed at build time:
phpabtpl composer.json | sed
'/@codingStandardsIgnoreFile/,/@codeCoverageIgnoreEnd/d' >autoload.php
Regards,
Robin
More information about the pkg-php-pear
mailing list