I have a Drupal 8 custom module that contains 5K of php in 10 classes. This code is production ready for the launch of a new website.
I also have code that runs from non-drush shell scripts. One example is the creation and distribution of a newsletter that runs from crontab. This pulls data from Drupal and creates a multi-part (html & plain text) email in multiple languages.
There is overlap between these two sets of code that would like to eliminate. How can I create a single php code library that can be shared between Drupal 8 and also used in standalone shell scripts?
There seems to be two approaches here:
(1) place all code in the custom module and Include it in shell scripts
I understand how to accomplish the custom module part of this. I don't know how to do the include into a stand-alone shell script from the Drupal directory.
(2) place all code in an external library and Include it in the custom module, the shell scripts and anywhere else I need it
This approach seems to have more flexibility. It addresses my original issue of sharing code between Drupal custom modules and stand-along scripts. It also allows the same code to be used in multiple projects -- separate Drupal 8 installs perhaps for difference clients.
How can I pull a custom php library (not on packalist.org) into my Drupal custom module? If this is possible, I will likely move most/all of my Drupal and Shell Script PHP code to a common external library that is under github change control.
Cache file /home/queryxchang/public_html/apps/frontend/config/../cache/-q-8-260354-common-custom-php-library-drupal-8-and-stand-alone-shell-scripts- could not be written