Independent custom scripts

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
sclg
User
Posts: 149
Location: UK

Independent custom scripts

Post by sclg »

I have a few 'helper' programs in the PHPM project folder which need to use Composer packages. These programs effect the database but, apart from being in the PHPM menu, they are otherwise independent of PHPM.

Because I want to use Composer packages, I add the line
require 'vendor/autoload.php';
to my programs

... but when I do this, everything fails with
Error: Undefined constant "PHPMaker2024\cpbartabs2024\PROJECT_CHARSET" in D:\wwwroot\cpbartabs\src\config.php on line 158

I assume autoload.php is loading config.php which is creating this error.
I don't know why PROJECT_CHARSET is undefined. 'Charset' is set to utf-8 on HTML-General.

Is there a way to fix this or is it just impossible for programs outside PHPM to utilise Composer packages like this?
Thanks


mobhar
User
Posts: 11732

Post by mobhar »

Did you mean you use Custom Files for your "helper" above?


arbei
User
Posts: 9390

Post by arbei »

sclg wrote:

I assume autoload.php is loading config.php which is creating this error.

No, autoload.php is only for composer packages, you need to include other required files yourself, you may refer to the index.php.


sclg
User
Posts: 149
Location: UK

Post by sclg »

mobhar wrote:

Did you mean you use Custom Files for your "helper" above?

No - it's not a 'Custom File'


sclg
User
Posts: 149
Location: UK

Post by sclg »

arbei wrote:

No, autoload.php is only for composer packages, you need to include other required files yourself, you may refer to the index.php.

So why is config.php being loaded? I'm not including ANY files except with "require 'vendor/autoload.php'; "


arbei
User
Posts: 9390

Post by arbei »

You included it indirectly, possibly by some other include files in your script, but you did not include the constants.php, hence the error.

You may post your code for discussion.


Post Reply