In the codeigniter I get this message :
Unable to load the requested file: home.php
controller :
cp/
Login
views :
cp/
home.blade.php
class Login extends BaseController {
public function __construct(){
parent::__construct();
}
function index()
{
$this->load->view('home','');
}
}
or :
class Login extends BaseController {
public function __construct(){
parent::__construct();
}
function index()
{
$this->load->view('cp/home','');
}
}
http://www.vitrinsaz1.ir/Mobile/Vitrinsaz/Pannel/cp/login
Hi when loading views remember to make sure that you name it correctly like in your instance you could do the following:
function index()
{
$this->load->view('home_blade');
}
remove the period in the name of the file and replace it with a underscore and then make sure the view file itself is named home_blade.php
Hey there I was also encountered by this error and my error was solved by rechecking the parent folder name try replacing cp.
$this->load->view('cp/home');
with this
$this->load->view('Cp/home');
I think this could be the issue..
My code was working fine on localhost but on server it wasn't loading the view. my error was solved by this.
If the code is correct and you still experiencing that error, change folder permissions :
chmod -R 777 "your folder"
I had a similar problem and that solved it.
Related
I am trying to add controller view in my existing project that consider model view controller structure in php with laravel.
class CashFlowdataController extends Controller {
public function index() {
return view('CashFlowdata::create');
}
}
When I implement this, it shows me error for,
InvalidArgumentException
No hint path defined for [CashFlowdata].
I have added file in route.php and web.php as added other controller data. Only for this one it shows message like this.
you code is wrong you should to something like this
class CashFlowdataController extends Controller {
public function index() {
return view('CashFlowdata.create');
}
}
here CashFlowdata.create
its means in laravel
folder structure should be
view>CashFlowdata>create.blade.php
laravel view() function is a helper to load view file
ref link https://laravel.com/docs/8.x/helpers#method-view
I had the same issue in nwidart/laravel-modules due to module.json file was miss place.
I move the file to the root of module now working fine.
My Master controller located in "admin" folder. View image
here
namespace App\Controllers\admin;
use CodeIgniter\Controller;
class Master extends Controller
{
function __construct(){
helper('url');
}
public function index()
{
$data["content"]="view_home";
echo view('template/template', $data);
}
}
In my Routes.php i added this
$routes->get('admin/master','Master::index',['namespace','App\Controllers\admin']);
when i access the page in the browser i get this error
404 - File Not Found
Controller or its method is not found: {0}::{1}
What am i missing?
My silly mistake when setting up the route. I've put a "," instead of "=>". See the correct route below.
$routes->get('admin/master','Master::index',['namespace' => 'App\Controllers\admin']);
Editing this post entirely as I realize that I did a poor job of explaining things as they are, and to reflect a few changes already implemented.
The issue: I have an app that has a normal front end, which works perfectly when accessed via app\public. I've added a backend and wish to use a different master layout. I have named the backend Crud. I created Crud\UserController and that has the following:
public function __construct()
{ $this->middleware('auth'); }
public function getIndex() {
return view('crud'); }
In my routes.php file I have the following:
Route::controller('crud', 'Crud\UserController');
I've tried placing that route inside and outside of the middleware group. Neither workds. I do have a file, crud.blade.php, that exists inside resources\views.
The issue is a 404 from apache every time I try to access app/public/crud. Specifically, this error:
The requested URL /app/public/crud was not found on this server.
I'm at a loss as to why the server is unable to find the route to crud.blade.php
ETA: The apache access log just shows a normal 404 when I attempt to access this page. The apache error log shows no errors.
The view() is suppose to point to a view file, that is something like example.blade.php which should contain the content you want displayed when the localhost:app/crud is visited. Then you can do view('example') without the .blade.php.
From your code, change
class UserController extends Controller{
//Route::controller('crud', 'Crud\UserController');
public function __construct()
{
$this->middleware('auth');
}
public function getIndex() {
return view('/');
}
}
to
class UserController extends Controller{
//Route::controller('crud', 'Crud\UserController');
public function __construct()
{
$this->middleware('auth');
}
public function getIndex() {
return view('crud'); // crud being your view file
}
}
I think you're mixing concepts. Trying to get here will always throw an error:
localhost://app/crud
To enter your app, just try to access:
http://localhost
appending a route you registered in your routes.php file. In your example, It'd be:
http://localhost/crud
If you register
Route::get('/crud', 'Crud\UserController#index')
Then you need an Index method inside UserController, which should return a view (in your example)
class UserController extends Controller{
public function __construct()
{
$this->middleware('auth');
}
public function index()
{
return view('crud');
}
}
P.S: about Implicit controllers, you have the docs here.
I have some issues with Routes in CI. also new with this framework. I want to ask you guys, (I have read similar example with my problem but it doesn't work for me).
(the link)
Codeigniter routing issues
every time I want to link another page in main page. CI said:![error routes][1]
An Error Was Encountered
Unable to load your default controller. Please make sure the controller specified in your Routes.php file is valid.
when i access this url in my browser: /test, i get the error routes.
here is a sample of my routes.php:
$route['default_controller'] = "frontline";
$route['404_override'] = 'error404';
$route['test'] = 'frontline/test';
and this my controller:
class Frontline extends CI_Controller {
public function __construct()
{
parent::__construct();
}
public function index()
{
$this->load->view('index.php');
}
public function test(){
echo "test";
}
}
When using Codeigniter to load the database, I am getting the following error message in a simple file where I load the database:
An Error Was Encountered
Unable to load the requested class: database
The controller for this code is called db.php, and the code for it is as follows:
<?php
class Db extends MY_Controller {
function __construct() {
parent::__construct();
$this->load->library('database');
}
public function index() {}
}
I do not have the database loaded in to autoload.php. I also know that I have the correct database information in my config.php file. My CodeIgniter application is in a subdomain if that might cause any problems.
Any ideas on what could be causing the problem? Thanks.
Use $this->load->database();
Instead of $this->load->library('database');