didn't get very far with trying myComponent.
For a first look, view the MyComponent Resource from the Manager. With the current package set to Example, check the Bootstrap radio button in the UI and click on the Submit button. If you scroll down, you should see a log of all the actions performed by the Bootstrap utility.
The UI is there, but get just a white screen, when trying to run bootstrap.
Do I need to configure something before running bootstrap on the Example-project ?
You shouldn't have to do anything (assuming that you installed it in Package Manager). It does require you to be logged into the Manager if you're running it inside MODX. The only other thing I can think of is if you modified the example.config.php file, it might not be valid PHP.
As always, check the error log and check the template used by the MyComponent Resource.
ok, its the php-version here.
myComponent doesn't work on php-versions before 5.3
for example because of this line in mcautoload:
$lower_basename = function ($string) {
return strtolower(basename($string));
};
and this one (lcfirst) in ObjectAdapter::createTransportFile:
$variableName = lcfirst(substr($type, 3) . 's');
after fixing these both for php < 5.3 bootstrap seems to work.
[ed. note: Bruno17 last edited this post 13 years, 7 months ago.]
Thanks for checking that out.
I get the lcfirst() issue, but strtolower() and basename() are both supposed to work in PHP 4 and PHP 5.
What did you change them to?
discuss.answer
$lower_basename = function()
this syntax was introduced in 5.3
added this to mcautoload.php:
if (!function_exists('lower_basename')){
function lower_basename($string){
return strtolower(basename($string));
}
}
and used it this way:
$fnames = array_map('lower_basename', $glob);
in objectadapter.class.php I added:
if ( false === function_exists('lcfirst') ):
function lcfirst( $str )
{ return (string)(strtolower(substr($str,0,1)).substr($str,1));}
endif;
Thanks Bruno. I'll add those to the next release.
Did you put both the functions outside the classes?
Let me know if you run into anything else.
yes, both outside of the classes at top of the files.
planing to create a UI with MIGX where I can put together the pieces for the config.
will see how this can go.
two more questions:
1. does myComponent support subpackages?
2. does it make sense to play with the dev-files from github or would you not recommend that.
1. Yes, it puts them in the core/packages directory during the install. You have to search locally for packages, then install them. I don't think that's documented very well yet. You just put the transport.zip files for them in the _build/data/subpackages directory and they go into the package. Installing them all during package installation is on the roadmap, as is moving them to the _build/data/subpakages directory automatically.
2. If you mean building MyComponent from the MyComponent files from GitHub, I'd recommend against it. It's a nightmare to work with because it assumes that the build package is somewhere *other* than the MyComponent directory. I have it set up to work with files in the mycomponent2 directory and I have to remember to copy everything over there manually whenever I do an edit. If you just mean grabbing some of the class and snippet files there to update them, that's probably fine, but I'd back up the originals first. There are some bugs fixed in the dev version.
If you just install the package, the snippet files should run from the command line or in an editor in addition to running in MODX.
in mycomponent.php
I replaced this:
$tplPath = $modx->getOption('mc.core_path', null, $modx->getOption('core_path') . 'components/mycomponent/') . 'elements/chunks/';
$newTpl = file_get_contents($tplPath . 'example.config.php');
with that:
$props = array();
$props['mycomponentCore'] = $modx->getOption('mc.core_path', null, $modx->getOption('core_path') . 'components/mycomponent/');
require_once $props['mycomponentCore'] . 'model/mycomponent/helpers.class.php';
$helpers = new Helpers($modx,$props);
$helpers->init();
$newTpl = $helpers->getTpl('example.config.php');
to be able to have my custom-tpl myexample.config.php as chunk or as file.