CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Is there a place for custom packages to live outside of the civicrm tree?
Pages: [1]

Author Topic: Is there a place for custom packages to live outside of the civicrm tree?  (Read 818 times)

kharding

  • I post occasionally
  • **
  • Posts: 75
  • Karma: 4
  • CiviCRM version: 4.2.7
  • CMS version: Drupal 7
  • MySQL version: Recent
  • PHP version: 5.3.16
Is there a place for custom packages to live outside of the civicrm tree?
December 10, 2012, 04:05:03 pm
Hi all,

I've come across an intriguing challenge:  currently, the payment processor I use (Stripe) has a package that's installed in the packages folder under the CiviCRM tree.

However, when we do an upgrade, we're told to completely delete the entire CiviCRM folder and upload the new one.  This nukes the packages folder.

Is there a way to put packages in the custom folder that's outside the CiviCRM tree?

totten

  • Administrator
  • Ask me questions
  • *****
  • Posts: 695
  • Karma: 64
Re: Is there a place for custom packages to live outside of the civicrm tree?
December 10, 2012, 04:26:52 pm
It looks like the code for the Stripe module tries uses this statement:

require_once ("packages/stripe-php/lib/Stripe.php");

This statement searches the PHP include_path for the given file, so it should still work as long as that file is accessible somewhere in the include_path. For example, on my laptop, the PHP include_path includes:

/Applications/MAMP/bin/php/php5.4.4/lib/php

You could a 'packages' directory in there. The CiviCRM-Stripe extension would find the necessary library if it's located at:

(My laptop) /Applications/MAMP/bin/php/php5.4.4/lib/php/packages/stripe-php/lib/Stripe.php

Under a Debian or Ubuntu system, the include_path should mention /usr/share/php, so you could put a packages directory in there. Then Stripe would find a file named:

/usr/share/php/packages/stripe-php/lib/Stripe.php

You could also declare a custom include_path in php.ini and then put the files in whatever directory you want.

In the future, I'd like to introduce "composer" for dependency management -- which would make it unnecessary to manually install the library. Alas, that's in the future.

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Is there a place for custom packages to live outside of the civicrm tree?
December 10, 2012, 04:32:50 pm

if u have a custom php path set, u can store the packages in that directory also, so:

/var/www/mycustomphproot/packages/stripe-php/lib/Stripe.php

should also work. this keeps your changes local to within your civicrm install

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

kharding

  • I post occasionally
  • **
  • Posts: 75
  • Karma: 4
  • CiviCRM version: 4.2.7
  • CMS version: Drupal 7
  • MySQL version: Recent
  • PHP version: 5.3.16
Re: Is there a place for custom packages to live outside of the civicrm tree?
December 10, 2012, 05:09:27 pm
Lobo, that's the custom PHP path directory set on admin -> Upload Directories, right? If so, problem solved. Thank you!

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Is there a place for custom packages to live outside of the civicrm tree?
December 10, 2012, 05:37:27 pm

yes. wanna add that to the stripe extension docs :)

r u using the stripe extension from drastik?

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

kharding

  • I post occasionally
  • **
  • Posts: 75
  • Karma: 4
  • CiviCRM version: 4.2.7
  • CMS version: Drupal 7
  • MySQL version: Recent
  • PHP version: 5.3.16
Re: Is there a place for custom packages to live outside of the civicrm tree?
December 11, 2012, 11:19:16 am
I am, yes. I will see if I can add it to the docs. 

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Is there a place for custom packages to live outside of the civicrm tree?

This forum was archived on 2017-11-26.