AnsweredAssumed Answered

AlfrescoPHP into Symfony2!

Question asked by hamidp on May 16, 2013
Hello,

I'm new to Alfresco and Symfony2 too, so please be understandable if I'm acting like a noob :D.

So the question is: how to include a AlrescoPhpLib into Symfony project?

I tried different kind of tutorials to include third part libraries into symfony2 but I have always the same error :
<blockcode>
FatalErrorException: Error: Class 'Repository' not found
in C:\wamp\www\Projet\src\Hmp\Bundle\Controller\DefaultController.php ligne …
</blockcode>

Source tutorial from : http://www.kiwwito.com/article/add-third-party-libraries-to-symfony-2

The library is in /vendor/alfresco/lib/Alfresco/src/.
I took the AlfrescoLoader from Ifresco - ClassLoader project to load all classes.

<php>
#/vendor/alfresco/lib/Alfresco/src/AlfrescoLoader
class AlfrescoLoader {
   public static function load($className){
      $directories = array(
            '',
            'Service/',
            'Service/Logger/',
            'Service/WebService/'
            
      );

      $fileNameFormats = array(
            '%s.php',
            '%s.class.php',
            'class.%s.php',
            '%s.inc.php'
      );

      // this is to take care of the PEAR style of naming classes
      $path = str_ireplace('_', '/', $className);

      if(@include_once $path.'.php'){
         return;
      }


      
      foreach($directories as $directory){
         foreach($fileNameFormats as $fileNameFormat){
            $path = $directory.sprintf($fileNameFormat, $className);
            $pathBefore = "../../".$directory.sprintf($fileNameFormat, $className);
            if(file_exists($path)) {
               include_once $path;
               return;
            }
            elseif (file_exists($pathBefore)) {
               include_once $pathBefore;
               return;
            }
         }
      }
   }
}

spl_autoload_register(array("AlfrescoLoader","load"));
</php>

Then I created a extended class:
<php>
<?php
# /vendor/alfresco/lib/Alfresco/Alfresco.php

require_once __DIR__.'/src/AlfrescoLoader.php';

class Alfresco extends AlfrescoLoader {
}
</php>


Then I added a Alfreco class to autoload:
<php>
$loader->registerPrefixes(array(
       'Alfresco' => __DIR__.'/../vendor/alfresco/lib',
    ));
</php>



I think, I did it corectly. But unfortunately it doesn't work :(


If someone could help me, I would apreciate it!

Thanks!

P.S: Sorry for my english!

Outcomes