We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

External Library ok in WAMP environment, but not in LEMP

Hi,

I recently moved my app from development(WAMP) to production environmnent(LEMP). I am facing some configration issues. In my app, i have set phalcon to autoload external libraries. It is working fine in WAMP, but not in LEMP. I have this class not found Error

The external library i am using is Sendgrid Api.

This is how i set phalcon to autoload the libraries.

1) Config.php Add the libraryDir path

    return new \Phalcon\Config(array(
              'application' => array(
              'controllersDir' => __DIR__ . '/../../app/controllers/',
              'modelsDir'      => __DIR__ . '/../../app/models/',
              'viewsDir'       => __DIR__ . '/../../app/views/',
              'pluginsDir'     => __DIR__ . '/../../app/plugins/',
              'libraryDir'     => __DIR__ . '/../../app/library/',
              'cacheDir'       => __DIR__ . '/../../app/cache/',
              'baseUri'        => '/',
         ),
    ));

2) Loader.php - Register the directories

    $loader->registerDirs(
      array(
          $config->application->controllersDir,
          $config->application->modelsDir,
          $config->application->libraryDir
      )
    );

3) Calling it in the controllers

     function sendEmail($emailaddress,$name,$message,$toemail){
        try{
            $sendgrid = new SendGrid($this->config->sendgrid->username, $this->config->sendgrid->password,$this->config->sendgrid->options);
            $email  = new SendGrid\Email();
            ...
        }
    }

My library folder resides in app folder.

Any help appreciated! The weird thing is that i do not know why it is working fine in WAMp but not in LEMP



58.4k

Please checking filename directory is lowercase or upcase , linux is discrimination lowercase betwent upcase



27.8k

Hi,

Renamed directory to lowercase but didnt have.

I am thinking that it might be an issue with namespaces. what do you think?



58.4k

That right , you tried autoload used namespace not using Register the directories



27.8k
edited Nov '14

i tried autoloading namespaces, but does not work. Is my path wrong>?

//Register some namespaces
$loader->registerNamespaces(array(
    'SendGrid\Email' => 'SendGrid/',
    'SendGrid\Smtpapi' => 'Smtpapi/',
    'SendGrid\Unirest' => 'Unirest/'
));

Here is my library file structure. i have a folder called library inside app folder.



58.4k
edited Nov '14

Not correct , i don't see full source your so i can't help you, but you refer to https://github.com/phalcon/vokuro/blob/master/app/config/loader.php

$loader->registerNamespaces(array(
    'SendGrid' => ROOT. 'SendGrid/',
));

You don't even describe the problem you're having? Just that it worked fine on Windows but not on Linux doesn't help us to help you.



27.8k

Hi Rewt0r, thanks for the reply. I am stucked on finding out what is the issue too. As you can see from previous post, suspected that it might be the namespace issue. Will keep u guys updated.