This topic is locked

PHPRunner 11 - Reusing code from multiple projects

10/14/2025 11:19:43
PHPRunner General questions
C
ChrisR author

I have a pool of reuseable codes, that in previous version of PHPRUNNER, I could keep in a specific folder.
eg: /projects/user-code

my projects eg. /projects/cars/sources folder would be updated when ever i made changes to the code.

Is there a way to have a folder on the disk that can be referenced by my project and included in the build?

ChatGPT 10/14/2025

Yes, in PHPRunner, you can manage reusable code by creating a specific folder for your custom code and referencing it in your projects. However, the exact method for including external files or directories may depend on the version of PHPRunner you are using. Here are some general steps to achieve this:

  1. Create a Shared Code Directory:

    • Create a folder on your disk where you can store your reusable code. For example, you can create /projects/user-code.


  2. Include the Code in Your Project:

    • In your PHPRunner project, you can include your reusable code files by using PHP's include or require functions. For example, if you have a file named myfunctions.php in your shared code directory, you can include it in your project as follows:
      include '/path/to/projects/user-code/myfunctions.php';
    • Make sure to use the correct path based on your server's directory structure.


  3. Using PHPRunner Events:

    • You can place the include statement in PHPRunner's event handlers (like BeforeDisplay, BeforeProcess, etc.) where you need to utilize the reusable code.
    • For instance, in the BeforeProcess event of a specific table, you could include your shared code:
      include '/path/to/projects/user-code/myfunctions.php';


  4. Update Your PHPRunner Project:

    • Whenever you update your reusable code in the shared directory, those changes should reflect in your PHPRunner project as long as you are including the correct path.


  5. Testing:

    • After making changes, be sure to test your project to ensure that the included files are functioning as expected.


  6. Considerations:

    • Be mindful of path permissions and ensure that the web server has access to the shared code directory.
    • If you are deploying your project to a different server, ensure that the path to your reusable code is also valid on that server.



By following these steps, you can effectively manage and reuse code across different PHPRunner projects using a single shared code directory.

Sergey Kornilov admin 10/14/2025

This is the case when ChatGPT is right on spot.

include '/path/to/projects/user-code/myfunctions.php';