Welcome Guest, Not a member yet? Register   Sign In
best way to debug CI
#1

Hi, 

I am starting out in CI and wondering what is the best way to debug CI ?
Reply
#2

(This post was last modified: 06-15-2018, 08:37 AM by php_rocs.)

@admin0,

You just asked an open ended question (You will receive many different answers). There are many ways to debug CI (it is a PHP framework after all). It depends on the developer and what they are comfortable with. I prefer a combination of Xdebug and Firefox Developer Tools (netbeans as my IDE). I also have a development and production copy of the software as well. This helps me to recreate the issue and solve it in DEV before pushing it to PROD.

P.S. CI also has built in features to assist in debugging as well. A Profiler and Logging just to name a few.
Reply
#3

Use echo exit
Use CodeIgniter's Profiler

Use XDEBUG

Use break points on and on and on...
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#4

sorry .. should have been specific...


so i developed code in my mac using MAMP.
3.1.9 with HMVC plugin .. works fine, everything runs as usual.
mamp env:   apache + php (osx)

Then i wanted to shift my work to the server to test.
env:  nginx + php  (fedora, no selinux)


i copy the whole code and database.
db connection is fine... no errors anywhere ..   the /welcome runs fine

however, all my hmvc modules ( applicaiton/modules/x) -- they give a 404

so localhost/test1/   localhost/test1/hello etc -- none of these work .. i just get a 404 with nothing in the error logs.
I bumped up the error level in the config to 4.

this is in my nginx conf 

     location ~ \.php$ {
                        try_files $uri $uri/ /index.php?/$request_uri =404;
                        fastcgi_split_path_info ^(.+\.php)(/.+)$;
                        fastcgi_pass unix:/home/site/private/php7-fpm.sock;
                        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                        fastcgi_param HTTP_PROXY "";
                        fastcgi_index index.php;
                        include fastcgi_params;
        }


I aleady have this:

//$config['base_url'] = '';
if(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on"){$ssl_set = "s";} else{$ssl_set = "";}
$config['base_url'] = 'http'.$ssl_set.'://'.$_SERVER['HTTP_HOST'];


so it is not due to URL.


what i did was to put this inside my applicaiton/modules/test1/controllers/test1.php

echo "break"; exit;
did not got executed .. 


then i went in to the do the same in

applicaiton/thirdparty/MX/Loader.php in the line just after <?php

it also does not got caught..


This leads me to believe that the hmvc plugin that worked plug and play is not even loading in the server.

so my question would be .. is there a way to know/figure out what files get loaded in what order, and why in my specific case, the plugin is not being loaded.


Thanks
Reply
#5

i also did this in the config: ( which was not needeed in local mamp)

$config['modules_locations'] = array(APPPATH.'modules/' => '../modules/');

no luck Sad
Reply
#6

i tested on windows and mac -- both case insensitive.
server = case sensitive ..


going line by line
echo "<pre>"; print_r($var) ; echo "<pre>";
echo "here" ; exit;

it helped figure out the issue.
filename was not caps Sad
Reply
#7

This .htaccess file is from FuelPHP but it solves a lot of server problems, so give it a try.

Code:
<IfModule mod_rewrite.c>

    # Multiple Environment config, set this to development, testing or production
    # Set the CodeIgniter Environment.
    SetEnv CI_ENV development
    #SetEnv CI_ENV production

    RewriteEngine on

    # NOTICE: If you get a 404 play with combinations of the following commented out lines
    #AllowOverride All
    RewriteBase /

   # Make sure directory listing is disabled
    Options +FollowSymLinks -Indexes

    # Add Font Types
    AddType application/vnd.ms-fontobject .eot
    AddType font/truetype .ttf
    AddType font/opentype .otf
    AddType font/opentype .woff
    AddType font/opentype .woff2
    AddType image/svg+xml .svg .svgz

    <FilesMatch ".(eot|ttf|otf|woff|woff2|svg|svgz)">
        Header set Access-Control-Allow-Origin "*"
    </FilesMatch>

    #RewriteCond $1 !^(index\.php|resources|vendor|assets|css|js|img|images|robots\.txt)

    # Restrict your site to only one domain
    # !important USE ONLY ONE OPTION

    # Option 1: To rewrite "www.domain.com -> domain.com" uncomment the following lines.
    #RewriteCond %{HTTPS} !=on
    #RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
    #RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

    # Option 2: To rewrite "domain.com -> www.domain.com" uncomment the following lines.
    #RewriteCond %{HTTPS} !=on
    #RewriteCond %{HTTP_HOST} !^www\..+$ [NC]
    #RewriteCond %{HTTP_HOST} (.+)$ [NC]
    #RewriteRule ^(.*)$ http://www.%1/$1 [R=301,L]

    # Remove index.php from URL
    RewriteCond %{HTTP:X-Requested-With}    !^XMLHttpRequest$
    RewriteCond %{THE_REQUEST}                ^[^/]*/index\.php [NC]
    RewriteRule ^index\.php(.*)$            $1 [R=301,NS,L]

   # make HTTP Basic Authentication work on php-fcgi installs
   <IfModule mod_fcgid.c>
       RewriteCond %{HTTP:Authorization} .
       RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
   </IfModule>

    # Send request via index.php if not a real file or directory
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d

    # deal with php-fcgi first
    <IfModule mod_fcgid.c>
       RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
    </IfModule>

    # no php-fcgi, check for sapi and fpm
    <IfModule !mod_fcgid.c>
        # for PHP5 sapi installations
        <IfModule mod_php5.c>
            RewriteRule ^(.*)$ index.php/$1 [L]
        </IfModule>

        <IfModule !mod_php5.c>
            # for PHP7 sapi installations
            <IfModule mod_php7.c>
                RewriteRule ^(.*)$ index.php/$1 [L]
            </IfModule>

            # for fpm installations
            <IfModule !mod_php7.c>
                RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
            </IfModule>
        </IfModule>

    </IfModule>

</IfModule>

Enjoy
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#8

I use the FirePHP extension in Firefox. Super convenient, and shows arrays as arrays, objects as objects, etc. I do prefer Firefox 48 for development, because Firebug still works, and Firebug is better than Firefox's developer console logging.
Reply
#9

I am using Codelobster IDE for it - http://www.codelobster.com/codeigniter.html
Reply
#10

(This post was last modified: 01-19-2021, 05:30 PM by richb201.)

I use phpStorm and xdebug and they work great together. I am debugging in a docker container too, just to make it a little more complex Smile.  A few years ago someone up on this forum recommended phpStorm, and I'd say it was one of the best decisions I have ever made. I am an IDE centric guy from way back.
proof that an old dog can learn new tricks
Reply




Theme © iAndrew 2016 - Forum software by © MyBB