using APPPATH |
I am moving code over from a Ci3 app to Ci4. I understand the APPPATH needs to be set in index.php. The reason I need it is that I have the following lines in my main Controller.
require APPPATH."../assets/MyReport.php"; require APPPATH."../assets/MyNexusReport.php"; require APPPATH."../assets/MyDashboard.php"; require APPPATH."../assets/MyDashboard2.php"; require APPPATH."../assets/OfficeHours.php"; require APPPATH."../assets/MySetup.php"; require APPPATH."../assets/MyValidate.php"; require APPPATH."../assets/MyExportExcel.php"; require APPPATH."../assets/MyExport6765.php"; require APPPATH."../assets/MyFormUser.php"; require APPPATH."../assets/MyFormUserE.php"; require APPPATH."../assets/MyFormRegister.php"; require APPPATH."../assets/MyFormAdminLogin.php"; require APPPATH."../assets/MainReport.php"; require APPPATH."../assets/MyExecutive_summary.php"; Is APPPATH still used or is there some place other than index.php were I set the APPPATH? Is this change covered in the docs?
proof that an old dog can learn new tricks
There are at least 4 Global directories in CI4 which are WRITEPATH,FILEPATH,ROOTPATH and APPPATH so for you to get your assets you shoul use ROOTPATH https://codeigniter.com/user_guide/gener...l#ROOTPATH
APPPATH indicates inside APP and ROOTPATH The path to the project root directory also, these files can be registered to autoload if you like PHP Code: <?php Codeigniter First, Codeigniter Then You!!
yekrinaDigitals
Thanks. But it seems that my ROOTPATH is not being set correctly. Here is the error:
require(/var/www/../assets/MyReport.php): failed to open stream: No such file or directory it should be /var/www/ci4/Views/MyReport.php I then tried using APPPATH instead and get this error: require(/var/www/app/../assets/MyReport.php): failed to open stream: No such file or directory it should be /var/www/ci4/app/../assets/MyReport.php In both cases I am missing the '/ci4' In what file can I fix up both the APPPATH and ROOTPATH? Same error!
proof that an old dog can learn new tricks
(07-04-2023, 08:15 AM)richb201 Wrote: I am moving code over from a Ci3 app to Ci4. I understand the APPPATH needs to be set in index.php. The reason I need it is that I have the following lines in my main Controller. What do you mean? Why do you need to set APPPATH in index.php? APPPATH is set in system/bootstrap.php by the framework. |
Welcome Guest, Not a member yet? Register Sign In |