How do I separate Codeigniter v4 MVC for admin and public? - php

I want to separate Codeigniter4 MVC for admin and public. In codeigniter3 this is very easy. But I am unable to do that in Codeigniter v4. I want to use system directory for both MVC. Can anyone help me?
Example for public
http:://abc.com
Example for admin
http:://abc.com/admin

Create an admin folder inside the public folder. Copy All files and folders from public folder to the admin folder
Edit the admin/index.php file. Add extra [../] in $pathsPath value
Create a new admin folder in App folder. Copy all files and folders from App folder to admin folder
Edit adnin/Config/Paths.php. Add extra [../] in every variables except $viewDirectory veriable.
This changes will make separate the admin and public MVC from each other. But the System folder will be the same.

Related

load a page inside a folder in codeigniter

I have changed the name of codeigniter and placed htdocs then in application folder I have created a new folder in that new folder again I created some folders for different web pages in each and every folder I added controllers,models,view files. Now I want to access a controller file which is in the new folder.
I tried with default route but not working..Can anyone suggest
Create as many folders as you want inside the controller model and view folders in CodeIgniter and not outside them if you really want to organise them.
Remember to set base URL in application/config/config.php file and default router inside the application/config/routes.php file.
If you have problems please comment below describing errors.

How to upload the laravel 5.2.42 project to cPannel?

please guide me how to upload the Laravel project to my cPanel I am very much confused.
you should add all the folders of laravel inside of public_html folder, and you need to move index.php and .htaccess file to the public_html directory from public directory. Now make changes index.php like this.
require DIR.'/bootstrap/autoload.php';
$app = require_once DIR.'/bootstrap/start.php';
That may work for you.
If you check your laravel project, there is a public folder inside it.
By default, your domain is pointed at the root level or on public_html. On you cPanel Domain settings, make sure your domain is pointed your Laravel application public folder.

How to I move my javascript resources into a local folder?

I wrote a small app using laravel 5.2. I tried to keep all of my code in one folder located outside the app folder.
I created a folder called modules. Inside the modules folder I have a folder for vendor name. Then, inside the vendor folder, I have a module folder which contains my code.
Here is a simple folder structure
app modules/vendor name/module name/...
I managed to move my controllers, views and a route file into the module name folder.
How would I move all of the javascripts located in the public folder into my module name folder so that everything inside is in the same folder?
Additionally, I have a lot of questions about the views being in the module folder. Is it a better practice to use $this->publishes() to publish views to the resources/views folder that comes with laravel? If so what are the benefits?
https://laravel.com/docs/5.2/packages
The benefit to publishing the views is that the end user, should they want/need to, then has the option to modify the views.
As for the javascript, its completely fine to contain the javascript in your modules folders as the docs mention. You have 2 options as to how they're then used. You can either choose to publish them which moves them into the public folder, or you can include them in your build process if you use elixir/gulp, etc. See https://laravel.com/docs/5.2/packages#public-assets
Edit:
To publish assets such as javascript files (they could in theory be anything, be that images, css, etc.) use the following from your packages service provider.
public function boot()
{
$this->publishes([
__DIR__ . '/path/to/script.js' => public_path('vendor/my-package'),
__DIR___ . '/path/to/another.js' => public_path('vendor/my-package'),
]);
}
The above will move both script.js and another.js into the /public/vendor/my-package folder. Just to explain __DIR__ is a PHP 'magic' constant which gives the directory the current php file is located in and public_path() is a Laravel function which gives us the location of the /public folder as some users choose to rename this folder to their specific configuration.

Integration of svg-edit or other programs on Laravel 4

I'm trying to integrate svg-editor with Laravel 4.
My current solution is to insert svg-editor.html file renamed as svg-editor.php inside my views folder and move the rest of files into the public folder. So now I've moved all the calls to js and css files into the edit view and all points to the public folder to let laravel load the needed files for svg-editor. js and css files are into assets folder and I call them with asset function:
<script>{{{ asset('/assets/js/ *original path from svg-editor* ') }}}</script>
public folder structure
app
public
vendor
svg-edit-2_6
Views folder: inside svg-edit-2_6 there's just svg-editor.php to be able to include on template with #include()
Of course this solution is messy because I've to modify all calls inside svg-editor code such as paths and URLs references. My question is if there's any way to let laravel to load this program without having to modify its params. I think could be possible to make some kind of calls froms start.php file but I could not find information about how to do this.
Could it be possible?

config codeigniter to run first project

I am using xampp and my document root in apache is set to htdocs directory by default. I download Codeigniter and unzip the project into this directory. It runs fine. Now I would like to use CI to create my own project. In the controllers folder I would like to create a folder named “myproject” and in the views folder of application folder, I would like to create a folder named “myproject_view” in which I will store all of my view files. My problem is I don’t know how to reset my config file (especially the route.php) for my project to work then.
CodeIgniter documentation doesn’t have a section to specify how to do this, the information given in URI Routing chapter is not enough for readers to understand this at all. Plus, What if I also would like to store my controler files in a nested folder (controllers > somefolder > someanotherfolders > etc) ? Thank you very much.
[UPDATE]
If you only leave all controller in controllers folder, and view files in the views folder, then things work out easily, what if you create a folder in teh controllers and a folder for view in the views folder. I guess you need to change your default route configuration. I would like to know HOW ?
CodeIgniter's documentation covers Sub-Folders for Controllers.
Views on the other hand, are always loaded from controllers. Therefore, you can write:
$this->load->view('my_folder_name/my_view');
Routes are not required here.

Categories