I'm currently developing on Windows with WampServer
and have Composer
working (with OpenSSL
), with Propel installed without issue, and everything seems to work fine. However, my project now needs to make use of the Equal Nest Behaviour
found here.
I thought this would allow me to use the propel behaviour. In my schema.xml
I have the following snippet:
<table name="friend">
<behavior name="equal_nest">
<parameter name="parent_table" value="user" />
</behavior>
</table>
But when I run propel-gen sql
I get the error:
[phingcall] Unknown behavior "equal_nest"; make sure you configured the propel.be
havior.equal_nest.class setting in your build.properties
The documentation says:
Then, if you don't use Composer, or an autoloader in your application, add the following configuration to your build.properties or propel.ini file:
Making me presume that I didn't have to put in the build.properties file. However, putting it in gives me the following error:
PHP Fatal error: Class 'EqualNestParentBehavior' not found in C:\home\movesleag
ue.com\vendor\craftyshadow\propel-equalnest-behavior\src\EqualNestBehavior.php o
n line 74
I wasn't sure if that was something to do with autoloading not working or namespaces (my schema has a namespace, but I get this same error when removing it too).
My composer.json
file looks like this:
{
"require": {
"craftyshadow/propel-equalnest-behavior": "dev-master"
}
}
Note: I did have Propel in there itself, but as the equalnest behaviour requires it itself I'm just letting that do its job.
So, what's the correct way to use Propel behaviours with Composer, and if I'm doing it right, why do I see the errors above?
Updates
I added this line to the top of EqualNestBehaviour.php
:
include __DIR__ . DIRECTORY_SEPARATOR . 'EqualNestParentBehavior.php';
And the SQL seems to be generated correctly without errors. However, changing that file doesn't seem clever to me! Could it be a problem with autoloading? Is there anything you can think of that I can do to test that?
I can confirm that using Equal Nest Behaviour
in my actual Propel
code works fine, using functions like addFriends()
- this is with the above changes still in place.
In my autoload_namespaces.php
file I have the following:
<?php
// autoload_namespaces.php generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
);
php composer.phar install
? Maybe try installing both Propel and the Behavior through Composer (it seems that just the Behavior is).. – Papagenacomposer install
works. As I said above, the behaviourrequire
s Propel 1.6.* itself. Of course, propel is installed ad working or I wouldn't be able to see the error messages from Propel at all. – Venezuelacomposer dump-autoload
– Shawna