Codeigniter hmvc Unable to load the requested file - codeigniter

We use:
PHP5.6.14
WINDOWS 7
Codeigniter 3.0.6
[Codeigniter HMVC][1]
Structure of our project:
application
----modules
--------auth
------------controllser
------------models
------------views
--------input
------------part1
----------------controllers
--------------------Part1.php
----------------models
----------------views
--------------------index.php
------------part2
----------------controllers
----------------models
----------------views
--------othermodule
------------controllser
------------models
------------views
in application/config/config.php we add
$config['modules_locations'] = array(
APPPATH.'modules/' => '../modules/',
APPPATH.'modules/input/' => '../modules/input/',
);
application/modules/input/part1/Part1.php
class Part1 extends MX_Controller
{
public function __construct()
{
parent::__construct();
}
public function index()
{
$this->load->view('index');
}
}
in application/config/routes.php We did not change anything
.htaccess
AddDefaultCharset utf-8
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
When http://musite.ru/part1 we see Error:
An Error Was Encountered
Unable to load the requested file: index.php
What could be the problem?

if you use hmvc from wiredesignz
your structure should look like
application
----modules
--------auth
------------controllser
------------models
------------views
--------input
------------controllers
----------------Part1.php
----------------Part2.php
------------models
------------views
----------------part1
--------------------index.php
----------------part2
--------------------index.php
--------othermodule
------------controllser
------------models
------------views
and your config.php should look like
$config['modules_locations'] = array(
APPPATH.'modules/' => '../modules/'
);
after that you should be able to get your request via
/input/part1/yourfunction/

Related

laravel backend page not found

This is vuejs and laravel project. I am facing issue in backend when I type complete url with admin then it says not found. This is happening because I was getting 404 laravel error in refresh inside components. So I used the below route in web.php
Route::get('/{any?}', function () {
return view('index');
});
In Vuejs, I am using the following:
I am using webhistory in route
I am also using fallback route
{
path: "/:pathMatch(.*)",
name: "NotFound",
component: NotFound,
},
backend is based on laravel. Here is the .htaccess data
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Send Requests To Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
laravel route
I tried the below one:
Route::get('/{any?}', function () {
return view('index');
});
and this one also
Route::get('/{any}', function(){
return view('index');//pointing to the index file of the frontend
})->where('any', '.*');
Route::get('/admin',[AdminAuthController::class,'Create'])->name('create.login');
Route::post('/admin/login',[AdminAuthController::class,'Store'])->name('store.login');
Please suggest

How to fixed route problem only / route working on live server not other?

I am using laravel 8 php 7.4. All route working fine on Local machine. But on Live serve Ubuntu 20.04 only one route is working that is / route.
My .htaccess file is in public folder and its content is
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
and my route file is
Route::get('/', function () {
return view('auth.login');
});
Auth::routes(['verify' => true]);
Route::post('user/login', [App\Http\Controllers\UserController::class, 'login'])->name('user.login');
Route::post('user/registration', [App\Http\Controllers\UserController::class, 'register'])->name('user.registration');
Route::get('/redirect', [\App\Http\Controllers\SocialAuthGoogleController::class, 'redirect']);
Route::get('/auth/google/callback', [\App\Http\Controllers\SocialAuthGoogleController::class, 'callback']);
Route::middleware(['auth', 'verified'])->group(function () {
Route::get('logout', [App\Http\Controllers\Auth\LoginController::class, 'logout'])->name('logout');
Route::get('show/energy/service/{id}', [\App\Http\Controllers\EnergyServiceController::class, 'show'])->name('show.energy.service');
Route::get('/home', [App\Http\Controllers\HomeController::class, 'index'])->name('home');
Route::get('student', [\App\Http\Controllers\StudentController::class, 'index'])->name('student');
Route::post('student/add', [\App\Http\Controllers\StudentController::class, 'store'])->name('student.add');
Route::get('student/edit/{id}', [\App\Http\Controllers\StudentController::class, 'edit'])->name('student.edit');
Route::post('student/update', [\App\Http\Controllers\StudentController::class, 'update'])->name('student.update');
Route::get('student/delete/{id}', [\App\Http\Controllers\StudentController::class, 'delete'])->name('student.delete');
});
When I visit on any link This page appear
enter image description here
How can i resolved this thanks in advance

Vue and Laravel SPA routes with params showing blank page on browser refresh and vue is not mounted on #app

I am using vue-router and Laravel for my applcation.
I have a url: http://mywebapp.com/post/{id}
It works when i navigate normally by clicking the above link and vue router loads the component post.vue with route id as route parameter.
But when i refresh the page everything goes blank and vue is not mounted on
<div id="app"></div>
I don't think this is a server configuration issue because my .htaccess file is correctly configured and i don't get a 404 response.
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
it just shows a blank page with no errors on the console so it's hard to trace the problem
The route
{
path: "/post/:id",
name: "Post",
component: Post,
meta: {
requiresAuth: false
}
}
The component
import Post from "./components/post/Post.vue";
when the component is loaded, it makes an Api request to fetch the post using the ID passed from the route
created() {
this.loading = true;
let url = `/post/${this.$route.params.id}`;
axios.get(url).then(response => {
this.loading = false;
this.post = response.data.post;
});
}
Route on api.php
Route::get('/post/{id}', 'PostsController#show');
Controller
public function show(Request $request, $id)
{
$post= Post::find($id);
return response()->json([
'post' => $clip
]);
}
The above codes works normally as expected when i navigate to a post but i just got a blank screen when i reload the browser with no errors reported on the console.
How do i fix this?
Your web.php find should contain a route that matches all routes:
Route::get('/{any}', 'SpaController#index')->where('any', '.*');
This way Laravel doesn't interfere with vue router links.

Laravel routing page not fount error while passing veriable

I am new to the Laravel while I reading the documentation I had a problem under routing.. it shows we can pass verifiable like this,
Route::get('user/{id}', function ($id) {
return 'User '.$id;
});
here what is the user is it Controller or veritable name. I tried to pass the verbal like below but it is getting error
my route code is ,
Route::get('/{id}', function ($id) {
echo 'ID: '.$id;
});
Your route is correct
Route::get('/{id}', function ($id) {
echo 'ID: '.$id;
});
i have tested it and its working fine
Can you check .htaccess file under public folder.
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
Also make sure about laravel project folder name is spelled correctly
As you can see in the url field you trying to get to public/32 and you should try to request such a url:
http://localhost/blog-laravel/public/user/32

I can't connect to assets & link path

I want to link path assets and other page. pls help me, how I should to do ???
Problems !
Now, I can connect to http://yoseigi.com/night/ ,but I can't connect assets inside.
[skeleton]/laravelfiles/app/view/index.blade.php
#extends('layouts.ace.login')
#section('pagecontent')
#{{ app_path() = }} <?php echo $path = app_path(); ?>
#stop
[skeleton]/laravelfiles/app/view/layouts/ace/login.blade.php (Code Assets Path)
{{-- Bootstrap --}}
{{ HTML::style('assets/bootstrap/css/bootstrap.min.css') }}
{{ HTML::style('assets/bootstrap/css/bootstrap-theme.min.css') }}
Style Sheet --> "Index.php" ?????
"NetworkError: 404 Not Found - http://yoseigi.com/night/Index.php/assets/bootstrap/css/bootstrap.min.css"
"NetworkError: 404 Not Found - http://yoseigi.com/night/Index.php/assets/bootstrap/css/bootstrap-theme.min.css"
yoseigi.com/dashboard
"NetworkError: 404 Not Found - http://yoseigi.com/night/dashboard"
Routes
[skeleton]/laravelfiles/app/routes.php
Route::get('/', function() {
return View::make('index');
});
Route::get('dashboard', function() {
return View::make('dashboard');
});
Directory
yoseigi.com
|--httpdocs
|--night
|--assets
|--ace
|--css
|--js
|--bootstrap
|--css
|--js
|--laravelfiles
|--app
|--config
|--app.php
|--view.php
|--views
|--layouts
|--login.blade.php
|--dashboard.blade.php
|--index.blade.php
|--routes.php
|--bootstrap
|--autoload.php
|--paths.php
|--start.php
|--packages
|--.htaccess
|--index.php
htaccess
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
#RewriteRule ^(.+)$ /index.php [L]
</IfModule>
Config
[skeleton]/index.php
require __DIR__.'/laravelfiles/bootstrap/autoload.php';
$app = require_once __DIR__.'/laravelfiles/bootstrap/start.php';
[skeleton]/laravelfiles/bootstrap/paths.php
'app' => __DIR__.'/../app',
'public' => __DIR__.'/../..',
'base' => __DIR__.'/..',
'storage' => __DIR__.'/../app/storage',
[skeleton]/laravelfiles/app/config/view.php
'paths' => array(__DIR__.'/../views'),
'pagination' => 'pagination::slider-3',
Instead of using the HTML facade, try using the asset() helper.
<link rel="stylesheet" href="{{ asset('assets/bootstrap/css/bootstrap.min.css') }}">

Resources