SeunMatt / codeigniter-log-viewer

This is a simple Log Viewer for viewing Code Igniter logs on the browser and via API clients
MIT License
96 stars 39 forks source link

[Update the Docs] Need to use URL helper #10

Closed samuelcarreira closed 5 years ago

samuelcarreira commented 5 years ago

Hi, first of all, thank for your work. After I starting to use this project I found an error on line 128 redirect($this->CI->uri->uri_string()); Called when you use some action like delete all files.

You need to load the URL helper if you want to use the redirect function. So I suggest to update the readme file and include that info to help other users like me ;-)

Sample instructions: Include the URL helper on the application/config/autoload.php file $autoload['helper'] = array('url');

SeunMatt commented 5 years ago

Hi @samuelcarreira There's no need to load the URI helper again since it's loaded automatically as stated in the docs here https://www.codeigniter.com/user_guide/libraries/uri.html

Unless you've modified your codebase not to autoload the URI helper - which I'm not sure of.

Cheers

samuelcarreira commented 5 years ago

Hi @SeunMatt, sorry to argue but the problem is with the URL helper ( https://www.codeigniter.com/user_guide/helpers/url_helper.html ) and not with the URI Library Class Library. Before I reply to you again I did a test with a completely fresh install of the CI 3.x framework (changes only on config.php and routes.php files) and I get the same error

An uncaught Exception was encountered
Type: Error

Message: Call to undefined function CILogViewer\redirect()

Filename: \webdev\cilog\application\vendor\seunmatt\codeigniter-log-viewer\src\CILogViewer.php

Line Number: 126

Thank you

PS: if you want you can browse the sample project that I created to view the issue cilog.zip

samuelcarreira commented 5 years ago

Other solution is to call the URL helper

My sample LogViewerController.php

<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class LogViewerController extends CI_Controller {

    private $logViewer;

    public function __construct() {
        parent::__construct();

        $this->load->helper('url');

        $this->logViewer = new \CILogViewer\CILogViewer();
    }

    public function index() {
        echo $this->logViewer->showLogs();
        return;
    }

    public function test() {
        log_message('error', 'Error');

        echo 'test ok';
        return;
    }
}