CodeIgniter Forums
No direct script access allowed - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: No direct script access allowed (/showthread.php?tid=86275)



No direct script access allowed - nadeem14375 - 01-25-2023

hi,
I am converting my CI3 application to CI4.
I am facing this error
No direct script access allowed
I have included the following code, but it always, says
Code:
No direct script access allowed
defined('BASEPATH') OR exit('No direct script access allowed');
Here is controller:
Code:
<?php
namespace App\Controllers;
defined('BASEPATH') OR exit('No direct script access allowed');

// echo "This is home home home";
// die();

// http://www.2my4edge.com/2015/12/complete-basic-insert-view-edit-delete.html

use App\Models\MainModel;
use App\Models\Users_model;
use App\Models\login_database;

class Home extends BaseController
{



RE: No direct script access allowed - kenjis - 01-25-2023

BASEPATH is not defined in CI4.
Remove the line "defined('BASEPATH') OR exit('No direct script access allowed');",
or define BASEPATH by yourself.


RE: No direct script access allowed - nadeem14375 - 01-25-2023

(01-25-2023, 11:15 PM)kenjis Wrote: BASEPATH is not defined in CI4.
Remove the line "defined('BASEPATH') OR exit('No direct script access allowed');",
or define BASEPATH by yourself.

hi,

can you share some example? I am new, how can define it?


RE: No direct script access allowed - kenjis - 01-25-2023

I recommend you remove the line in all your files.
Because it is not necessary in CI4.

Add this in app/Config/Constants.php:
PHP Code:
define('BASEPATH''whatever');