I am having trouble using this (https://github.com/gsouf/google-url) library as a codeigniter library.
I've downloaded the library from GitHub and placed it in this folder:
application/libraries/google-url-master
And created this file to setup the library as a codeigniter library:
libraries/googleurl.php
<?phpif (!defined('BASEPATH')) exit('No direct script access allowed');class GoogleUrl {
private $g;
function __construct() {
require_once( APPPATH . 'third_party/google-url-master/autoload.php' );
$this->g = new \GoogleUrl;
}
And then load if trough controller with this line: $this->load->library('googleurl');
But when I load the library it gives me this error:
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 65488 bytes) in \application\libraries\googleurl.php on line 11
Looks like its in a loop, but I cannot figure out why this is happening.
I thought/hoped the anser of antoni would help me out, but no success so far:
How to Integrate SEOStats with Codeigniter?
Thanks in advance,
Martijn
Related
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
require_once(dirname(__FILE__) . '/dompdf/autoload.inc.php');
class Pdf{
I cant generate a pdf from, keeps says dompdf class not found, tried extending CI_Controller, even extending dompdf class still cant resolve.
If you are using composer then it would be an easy task to add DOM Pdf compatibility in your project. This is the Repository of DOM Pdf.
You can Install it By using Composer Package Manager
composer require dompdf/dompdf
And You have to enable Autoload in your Codeigniter Project.
To autoload resources, open the application/config/autoload.php file
and add the item you want to load to the autoload array. You’ll find
instructions in that file corresponding to each type of item.
Additionally, if you want CodeIgniter to use a Composer auto-loader,
just set $config['composer_autoload'] to TRUE or a custom path in
application/config/config.php.
And Finally, Set the Path of vendor/autoload.php in application/config/config.php
$config['composer_autoload'] = FCPATH . 'vendor/autoload.php';
Please Check the CI3 Documentation Here https://codeigniter.com/userguide3/general/autoloader.html
I uploaded the paypal php sdk to my codeigniter app inside the libraries/paypal folder.
In the same folder I create a paypal.php file and inside it I insert this code:
<?php
require __DIR__ . '/common.php';
use PayPal\Api\Amount;
use PayPal\Api\Details;
use PayPal\Api\Item;
use PayPal\Api\ItemList;
use PayPal\Api\Payer;
use PayPal\Api\Payment;
use PayPal\Api\RedirectUrls;
use PayPal\Api\Transaction;
class Paypal{
function createPayment(){
$payer = new Payer();
$payer->setPaymentMethod("paypal");
//....
}
}
but when I call this function in my controller I get this error:
Fatal error: Class 'PayPal\Api\Payer' not found in '....'
I don't understand why instead common.php is imported correctly.
In my app I also have the Facebook sdk and I created the same structure to use it and it works
Best way is to follow these steps.
Download the SDK using composer.
Upload the vendor directory into codeIgniter Application root.
Then in the index.php file put this line
include "./vendor/autoload.php";
Now you can access the Paypal SDK and its dependent libraries easily.
So I'm trying to troubleshoot why CodeIgniter won't display any output (except for 404's and such). I've checked everything from error logging in php and apache and codeigniter, to the module rewriting. Everything seems to be configured just fine.
I started to dive into the CodeIgniter core files and noticed that it was crashing on the line below that tries to instantiate the requested controller class:
$class = $RTR->fetch_class();
$method = $RTR->fetch_method();
echo 'looking for class: ' . $class . '<br/>';
if(class_exists($class) == false) {
)
{
echo 'class does not exist: ' . $class;
show_404("{$class}/{$method}");
}
}
/*
* ------------------------------------------------------
* Is there a "pre_controller" hook?
* ------------------------------------------------------
*/
$EXT->_call_hook('pre_controller');
echo '<br/>after precontroller';
/*
* ------------------------------------------------------
* Instantiate the requested controller
* ------------------------------------------------------
*/
// Mark a start point so we can benchmark the controller
$BM->mark('controller_execution_time_( '.$class.' / '.$method.' )_start');
echo '<br/>before class init: ' . $class;
$CI = new $class();
echo '<br/>after class init';
This is within the /core/CodeIgniter.php file. Here is the output:
CodeIgniter.php
looking for class: servicecontroller
after precontroller
before class init: servicecontroller
Basically it's telling me that it can find the servicecontroller class, but when it tries to instantiate it, it crashes. php error logging is enabled, and display_errors is on. If I force a php error anywhere near here, I see it on the page, but not this one. Does anyone have any idea why it can't get past this line?
servicecontroller.php is arranged like this:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class servicecontroller extends CI_Controller {
}
Okay, the root of this problem was an error connecting to the database using mysql_connect. For some reason, it would not produce any error whatsoever, nor would "or die("error..."); do anything. This was because we were using php 5.4 on the server, and mysql_connect does not seem to be supported anymore, unless you have mysqlnd installed. The solution was to switch our database driver to 'mysqli', which CodeIgniter luckily has a driver for, and then install php5-mysql with: apt-get install php5-mysql
Hope this helps anyone else.
I have solved my issue.
Open your: config/database.php
Find: $db['default']['dbdriver'] = 'mysqli';
Replace that with: $db['default']['dbdriver'] = 'mysql';
Or, enable the "mysqli" extension in PHP.
Nothing to do in core system folder.
Update system folder to the latest one
Check .htaccess file within the index.php folder
Check your config/route.php file
If in host check mod_rewrite apache module is enabled
I had this problem using Expression Engine, the issue was the database connection -- I am using Vagrant so I had to set the port in the database config file and then it worked.
*edited to be more clearly
I'm deploying CI 2.0.3 with Modular Extensions (HMVC) in two environments, one is Windows -for development- and the other is Linux -for production-. Both environment has identically folders and files structure. Currently I am having a problem.
After integrating the Modular Extensions to CI by following the manual. The first thing I did was moving the default Welcome MVC that comes with CI to Modular Extensions HMVC. Both environment successfully moved and can be viewed on the browser.
But when I create other modules, it worked on Windows environment but not on Linux. On Windows when I call the module the browser shows the page as expected. But on Linux it shows just white blank page. Not even an 404 err page, which means it is not a broken link.
Can anyone tells me what is wrong in the CI?
Directory structure
/application
-/cache
-/config
-/controllers
-/core
--MY_Loader.php
--MY_Router.php
-/errors
-/helpers
-/hooks
-/language
--/english
-/libraries
-/logs
-/models
-/modules
--/csv_game_credit
---/controllers
----csv_game_credit.php
---/models
----csv_game_credit_db.php
---/views
----welcome_message.php
--/welcome
---/controllers
----welcome.php
---/views
----welcome_message.php
-/third_party
--/MX
--Base.php
--Ci.php
--Config.php
--Controller.php
--Lang.php
--Loader.php
--Modules.php
--Router.php
-/views
Welcome controller
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Welcome extends CI_Controller {
public function index()
{
$this->load->view('welcome_message');
}
}
Csv_game_credit controller
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Csv_game_credit extends CI_Controller {
function __construct() {
parent::__construct();
$this->load->model('Csv_game_credit_db');
$this->load->dbutil();
$this->load->helper('file');
}
public function index()
{
$this->load->view('welcome_message');
}
}
Is this has something to do with the Linux's folder permission? I will try to change the folder permission to 777 and update you guys
Thanks before
You need to extend MX_Controller not CI_Controller
If you are using the HMVC extension from wiredesignz you need to verify that you put the MX folder in the application/third_party folder and the MY_Loader.php and MY_Router.php in the application/core folder.
When this has been verified, create the folder modules in the application folder ('application/modules`).
Now, what is a little tricky about this solution is that when you wan't to create a module, the default controller has to be named the same as the module - the default controller name specified in the config doesn't apply here.
This means that if you create a module called `mymodule', you should create a folder/file structure like this:
application/modules/mymodule
- /controllers
- - mymodule.php
- /views
- - whatever.php
In the controller, located at application/modules/mymodule/controllers/mymodule.php you just create a controller as you would normally do:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Mymodule extends CI_Controller {
public function index()
{
$this->load->view('whatever');
}
}
I can't manage to call show_error from inside a library file I get
Warning: include(application/errors/error_php.php) [function.include]: failed to open stream: No such file or directory in E:\project\SOURCE\system\core\Exceptions.php on line 167
Perhaps you need to create a CI instance?
To access CodeIgniter's native resources within your library use the get_instance() function. This function returns the CodeIgniter super object.
more here
So perhaps something like
$CI =& get_instance();
$CI->show_error('something is not right here . . . ');
Will do what you want.