smarty not working in codeigniter - codeigniter

I installed Smarty in Codeigniter and it's not really working. Here is what I did:
I followed this instructions:
http://sunwebexpert.com/books/detail/PHP/integrating-smarty-and-codeigniter.html
But I also put another file in the library: parser.php which is a library to do parsing (I've used it before with smarty and worked well)
the on Codeigniter's autoload.php wrote this:
$autoload['libraries'] = array('parser','smarty');
On main controller I wrote this function to test:
public function index()
{
$this->data['d'] = 2;
$this->parser->parse('base/test.tpl', $this->data);
}
but the result is no error display and I see the variable 'd' as it is wrote in the template:
{$d}
So I have two questions:
Why can't I see the variable value if I installed smarty as I did before in other projects?
How can I enable to see errors if there are?

The problem is that in codeigniter, there is a built-in library called Parser. That's why this may cause conflict with your library name. Try to rename your library name or use built-in library.
Here is how to display error on codeigniter.
Hope it will be useful for you.

Related

location of helper function in Laravel 5

I am using Laravel 5 and new in this Platform. I studied about URL:asset In the earlier version of PHP, we could find the helper function in Auto Load or config files.
Do the helper function list exists somewhere in the Framework directory where if we want to change something in the helper function according to our need.
The helper functions are present in
/vendor/laravel/framework/source/illuminate/Foundation/helpers.php
You can find your helper function inside app.php as facades are registered on app.php and service container would let you resolve the class anywhere you want by use shorthandname or registered name;

Laravel Controller not working

I'm very new to the Laravel framework and am trying to load a simple controller in my browser to slowly get the hang of things.
I have a file that's titled users.php inside of the the laravel/app/controllers/ folder and it looks like this:
class UsersController extends BaseController
{
public $restful = true;
public function action_index()
{
echo 'hi';
}
}
In the routes.php file, I have
Route::get('users', 'UsersController#index');
But, when I go to
http://localhost:8888/laravel/public/users
I'm greeted with a message that says "ReflectionException
Class UsersController does not exist"
I'm not sure if this is because I didn't install the mcrypt extension of PHP. But, when I checked the php.ini file on MAMP, it said that it was enabled. Upon entering
which PHP
in my terminal, it said /usr/bin/php. So, it might not be using the correct version of PHP.
I'm not entirely sure if this is a routes problem or if it's stemming from an absence of a vital PHP extension.
Thanks a bunch!
You need to use the Route::controller method to reference your Controller:
Route::controller('test', 'TestController');
...and rename your file (as Cryode mentions ) to be TestController.php.
Note - if you want to use the filename as test.php, then you will need to use composer to update the autoload settings.
Finally, the format of names for Controller methods changed in Laravel 4, try renaming the method
public function action_index() {}
to be
public function getIndex() {}
the get represents a HTTP GET request... the same applies for post (HTTP POST) and any (GET or POST.. )
I'm not familiar with that part of Laravel's source, so I'm not entirely certain that this is the issue, but your controller file name should match the controller class name, including capitalization.
So users.php should be UsersController.php. Now, when I do this myself on purpose, I get a "No such file or directory" error on an include() call, so that's why I'm not certain that's the sole cause of your problem. But it may be a start.

google calendar with codeigniter

I'm trying to integrate Google Calendar in my php application (I use CodeIgniter for this).
I have a problem with my controller calendar.php.
<?php
session_start();
Class Calendar extends Controller {
function Calendar(){
echo 'start';
parent::Controller();
echo 'okkkkkkkk';
require_once '/home/me/framework/ZendGdata/library/Zend/Loader.php';
Zend_Loader::loadClass('Zend_Gdata');
Zend_Loader::loadClass('Zend_Gdata_AuthSub');
Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
Zend_Loader::loadClass('Zend_Gdata_Calendar');
}
but there is a problem with parent::Controller() because 'okkkkkk' is not printed.
Could anyone help me please?
Change
parent::Controller();
to
parent::__construct();
parent::Controller() doesn't work in CI because as of CI 2.1.2, the constructors are declared using PHP's __construct() method.
As a sidenote, it seems you are using an older version of CI. CI 2.o onwards, the base controller class is called CI_Controller as opposed to just Controller. You should look into updating your project by replacing the system folder.
You can find the full working code in this following link https://github.com/omerkamcili/ci_google_calendar_api.
After down loading the code create your service account, OAuth client Id's in the following link http://console.developers.google.com.
Then replace the client_id,client_secret,redirect_uri's in your project file in the following path -> /project_folder/application/config/client_secret_846685841138-t0a5b9d2i655e7km54md8j440jcg5rr5.apps.googleusercontent.com.json file
Finally download and replace the google-api-php-client in the following file path /project_folder/application/third_party/google-api-php-client

HMVC Unable to load the requested file

Hello i have some problem, i use Codeigniter Modular Extensions - HMVC.
Problem is when i try to show my module.
An Error Was Encountered
Unable to load the requested file: quicklinks_show.php
I have two modules
1.Dashboard
2.Quicklinks
The problem arises when I try to call and show another module in dashboard module.
I put this code in Dashboard/view/dashboard_view.php module
<div id="modules">
<?php modules::run('quicklinks/show');?>
</div>
In my Quicklinks modules i have simple Show() function
public function show(){
$this->load->view('quicklinks_show');
}
Make sure you have the view folder is named correct, so controller*s*, model*s* and view*s*
Try this pull request:
https://github.com/EllisLab/CodeIgniter/pull/1818
I tested that and it looks like this is the best hmvc solution.
Download here: https://github.com/dchill42/CodeIgniter/tree/hmvc_unit
It may be too late to reply but you may get the answer in this in-depth article of HMVC.

Setting up Codeigniter HMVC with tank auth

I am having trouble getting a working Codeigniter version 2.0.3 with hmvc and tank auth(set up as a module) setup properly. I have installed CI properlly and then install HMVC with these directions https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc/wiki/Home
I get to my welcome controller/view as example just fine which means the HMVC is working. Next I try to add tank auth to the project by adding it to a folder in the modules folder. It has the proper controller/view/model etc.. setup within the tank auth. I even added in routes something like
$route["auth"]="auth/login";
I also extended the controller within the auth module to MX_Controller like as directed. Also in the constructor I have :
$this->load->helper(array('form', 'url'));
$this->load->library('form_validation');
$this->load->library('security'); <--failing to load this
$this->load->library('tank_auth');
$this->lang->load('tank_auth');
$this->form_validation->CI =& $this;
It seems to be redirecting fine to the module however it comes up with an error saying ::
An Error Was Encountered
Unable to load the requested class: security
What am I doing wrong? Does any one have a working CI installation with HMVC and tank auth as a module so I can see how its done? I'm new to HMVC, thanks
I found the same problem, but i solved by simple adding a comment to the
$this->load->library('security');
so it will look like this:
//$this->load->library('security');
since security its now part of the codeigniter core, i guess its already loaded by default, and everything seems to be working pretty good
it is in Helper now according to CodeIgniter 3.0 user guide
try:
$this->load->helper('security');
I fix this, by creating Security.php file in application/libraries directory with the following code:
require_once(BASEPATH.'core/Security.php');
class Security extends CI_Security { }
I found a solution, I simply took the security.php file from codeigniters system/core folder and dropped it into system/libraries.
move the file security.php from system/core to system/libraries
then edit core/codeigniter.php line number 204 from $SEC =& load_class('Security', 'core'); to $SEC =& load_class('Security', 'libraries');
Security.php is present in "codeigniter/system/core/Security.php"
so provide this path your problem gets solved easily
load->library('../core/security');
I Read CodeIgniter 3.X User Guide and I was found that "Security" is available as a 'helper' Now.
So you need to change this;
$this->load->library('security');
into
$this->load->helper('security');
XSS Filtering
The Input class has the ability to filter input automatically to prevent cross-site scripting attacks. If you want the filter to run automatically every time it encounters POST or COOKIE data you can enable it by opening your application/config/config.php file and setting this:
$config['global_xss_filtering'] = TRUE;
You need to read a CodeIgniter 3.0 User Guide there are so many changes and implementation or please Refer change log.

Resources