PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, August 30, 2022

[FIXED] How to use PECL extension from inside of framework

 August 30, 2022     pear, pecl, php, symfony     No comments   

Issue

I am using PECL extension trader

It works inside the ./src/MyBundle/Command/MyCommand.php without any installtion or include.

function calcByCode()
    \trader_ma($array, 5, TRADER_MA_TYPE_EMA);
}

however inside the Controller

./src/MyBundle/Controller/MyController.php

public function indexAction()
{
    \trader_ma($array, 5, TRADER_MA_TYPE_EMA); 
    //(or trader_ma($array, 5, TRADER_MA_TYPE_EMA);)

    return $this->render('AcmeTopBundle:Default:index.html.twig');
}

returns error like this

Fatal error: Call to undefined function TopBundle\MyController\trader_ma()

How can I use PECL extension inside the condroller of Symfony2 framework??


Solution

It's mostly a case of the extension not being installed correctly. To know if the extension if installed correctly or not, make use of phpinfo for both cli and web ( cgi / fpm ).

There is a chance that the extension is enabled only in the php.ini for PHP CLI and not for fpm / cgi ( web server ) . So make sure you enable the trader module in the appropriate php.ini file .



Answered By - Vamsi Krishna B
Answer Checked By - Katrina (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing