Use PHPMaker scripts in my existing website (v2021)

Tips submitted by PHPMaker users
Post Reply
psdann
User
Posts: 3

Use PHPMaker scripts in my existing website (v2021)

Post by psdann »

I have used PHPMaker for a long time as a complement to my developments in web pages. Without a doubt, PHPMaker is a great tool for creating forms, graphics and more.
But generally at least for my needs, I always required to use the benefits of PhpMaker and use it freely in my own web template.
PHPMaker 2019 was a great leap for it and finally there was the integration tool that I had always needed, however this was removed in later versions, so the 2021 version no longer allowed me to use my own templates Because my specific need is to access the data and some functions of PHPMaker because I have to find a solution and it is the one that I want to share with the community, as it could be useful to others.

Understand that my specific need is PHPMaker for forms and then that DATA read it in a separate folder example

Admin / PhpMaker
miwebPublica / My web Files

In order to achieve this it has been enough for me to include the following lines of code in the files of my website

namespace PHPMaker2021\PHPMAKER_PROJECT_NAME;

$RELATIVE_PATH = "ROUTE_TO_FOLDER_PHPMAKER-FILES/";

require_once $RELATIVE_PATH."vendor/autoload.php";
require_once $RELATIVE_PATH."src/constants.php";
require_once $RELATIVE_PATH."src/config.php";
require_once $RELATIVE_PATH."src/phpfn.php";
require_once $RELATIVE_PATH."src/userfn.php";

Adding these lines of code allows me to access the database and the PHPMAKER functions

I hope to be helpful


shahparzsoft
User
Posts: 361

Post by shahparzsoft »

I am using the same pattern and want to echo currentuserid, but nothing is successfull. My code is :

<?php

namespace PHPMaker2021\pgoc;

$RELATIVE_PATH = "c:/xampp/htdocs/pgoc/";

require_once $RELATIVE_PATH."vendor/autoload.php";
require_once $RELATIVE_PATH."src/constants.php";
require_once $RELATIVE_PATH."src/config.php";
require_once $RELATIVE_PATH."src/phpfn.php";
require_once $RELATIVE_PATH."src/userfn.php";

echo CurrentUserID();
echo currentuserlevel();

?>


arbei
User
Posts: 9292

Post by arbei »

  1. v2021 uses MVC and routing, it is is not recommended to use this approach to bypass routing (and try to access the physical script directly) in the v2021 generated application.
  2. If you must use this approach, the $RELATIVE_PATH should be the relative path of the project folder (relative to the the script, e.g. if the script is at one folder level lower than the project folder, it is "../"), it is not an absolute path (e.g. "c:/foo/bar/").

Post Reply