How to use regular models/libraries along with package in codeigniter? - php

I'm having trouble using packages in codeigniter.
My folder layout is:
/applications
/regular_application1
/regular_application2
/common_pkg
In common_pkg, I have models that I want both applications to be able to use. In order to load the package, I added the route to it in $autoload['packages']-
$autoload['packages'] = array(FCPATH.'applications/common_pkg/');
This works fine, in both applications in any controller I can now load the models using:
$this->load->model("Balance_model");
The problem is that after this, I want to load a library from within my regular_applicationx. So I call from within my controller (the controller is in regular_applicationx:
$this->load->library("Selections_library");
But when I try to use the library, I get:
A PHP Error was encountered
Severity: Notice
Message: Undefined property: Selections::$Selections_library
I'm surmising from the above that once I set my package to common_pkg in the autoload, CodeIgniter is only looking there for libraries and models. Is there any way to load both from the regular application and common_pkg?
Thanks!

Related

How can I use Cache during application bootstrapping?

I am migrating a Laravel 4.2 application to Laravel 5.1.
During bootstrap, when loading the mail configuration file (config/mail.php), I want to read my SMTP configuration from DB and cache it.
In order to do that I use an Eloquent model class, in which I use the Cache facade's remember() function to get the data I need.
It used to work in 4.2, but after switching to 5.1, I get the following error message:
Call to a member function remember() on a non-object
This happens after I put the following line at the top of the class:
use Illuminate\Support\Facades\Cache;
Without that line I got a Class 'Cache' not found error message.
Any idea what am I missing? Is this even possible in 5.1?
Thanks a lot!

PHP Framework Zend not Working

When I try to load it some error occurs that prevents the rest of the page from loading.
My file basically looks like this:
use Zend\Form\Form;
include 'Zend/Form/Form.php';
$form = new Form();
// Page Content
What am I doing wrong?
PHP Errors:
Fatal error: Class 'Zend\Form\Fieldset' not found in /Applications/MAMP/htdocs/wordpress/wp-content/plugins/contest-guess-image/Zend/Form/Form.php on line 24
You can't use ZF2 without autoloading. Composer makes this easy, if you're not using composer you'll need to setup the ZF2 standard autoloader yourself before using any other ZF2 classes.

PHP Fatal error: Class 'sfConfig' not found in while run PHP Excel Symfony1.4

i am trying to run basic example of phpExcel in symfony1.4 and i am getting this error
C:\wamp\www\orangehrm-3.01\symfony>php plugins/sfPhpExcelPlugin/examples_1_2/01s
imple.php
10:39:01 Create new PHPExcel object
PHP Fatal error: Class 'sfConfig' not found in C:\wamp\www\orangehrm-3.01\symfo
ny\plugins\sfPhpExcelPlugin\lib\sfPhpExcel.class.php on line 9
any idea will be approciate.
The code for this plugin's examples is a bit strange. It uses the sfConfig class to read Symfony config variables but doesn't initialize nor include any Symfony code (hence the error).
In fact when you look at the code of this plugin you'll see that all it does is set some configuration when instantiating PHPExcel object. I would skip the plugin altogether and just use the PHPExcel directly in your project (you can either include it in the controller where you use it or in the ProjectConfiguration.class.php to make it available for the whole project (not recommended though).

Fatal error installing Twiggy with Codeigniter/HMVC

when trying to install twiggy with codeigniter/HMVC I get the following error:
A PHP Error was encountered
Severity: Notice
Message: Undefined property: CI::$twiggy
Filename: MX/Controller.php
Line Number: 58
I have installed twiggy as described on http://edmundask.github.io/codeigniter-twiggy/
The only thing I did was change the name of the spark MY_Loader.php to MY_Spark_Loader.php because it had the same name as the HMVC MY_Loader.php
I have autoloaded twiggy in the autoload.php like this:
$autoload['sparks'] = array('twiggy/0.8.5');
My controller looks like this:
<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class Test extends MX_Controller
{
public function index()
{
$this->twiggy->display();
}
}
Any help to get this running would be much appreciated!
Make sure that the autoloader is pointing to the correct location. Mine looks like this: $autoload['sparks'] = array('../tools/sparks/Twiggy/0.8.5');
Did you follow this instruction
http://getsparks.org/set-up-mx
It explains how to install spark manager with hmvc, but there is a bug, if you run $this->router->fetch_modules() in modules which is run from another module it doesn't return current running module, it returns original module.
To fix that, don't replace MX/Loader.php with the one provided there, just use hmvc original file, but add two functions to load sparks from that loader to hmvc loader file.
For MX/Modules.php do the same thing, just take spark specific code to hmvc original file.
Sorry for my bad english. Hope you understand

Joomla installfile "Call to undefined method"

I'm rewriting a component, and I've been following
a tutorial here: http://docs.joomla.org/Managing_Component_Updates_with_Joomla!1.6_-_Part_3
In the install file code they compare the existing installed component with the new
install file's params. The code to get the installed version is this:
$oldRelease = $this->getParam('version');
When I run this, it dies with the following:
Fatal error: Call to undefined method
com_mycomponentInstallerScript::getParam()
I thought that in Joomla 1.6+ the params were accessible
automatically via the getParam?
Thanks for help.
If you look at the full script you linked to, they added a function getParam to the class. since com_mycomponentInstallerScript isn't extending an existing Joomla class, that function doesn't exist unless you define it.

Categories