Codeigniter Routing with HMVC not working - codeigniter

I'm using Codeigniter with HMVC, I Have a sub controller with a name differed from Module name
- modules
- manage
- controllers
- manage.php
- views
- dashboard.php
- properties
- controllers
- properties.php
- manage.php
- views
- properties.php
- manage.php
- projects
- controllers
- projects.php
- manage.php
- views
- projects.php
- manage.php
if the url like this (index only working)
sitename.com/manage/proprties
this working fine, but if I passed some parameters,( Error 404)
sitename.com/manage/properties/add
OR
sitename.com/manage/properties/edit/10
My Routing like this
$route['manage/(:any)'] ="$1/manage";
$route['manage/(:any)/(:any)'] ="$1/manage/$2";
$route['manage/(:any)/(:any)/(:num)'] ="$1/manage/$2/$3";
How to make URL sitename.com/manage/properties/edit/10 working?

In routes you have wrong. Depending on your version of codeigniter.
https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc
Examples:
$route['default_controller'] =" folder/controller/index"; // Only works codeigniter 2 so far codeigniter 3 will not allow is bug in codeigniter 3
$route['name'] =" folder/controller/index"; // Example
$route['manage'] =" manage/manage/index";
$route['manage/add'] =" manage/manage/add";
$route['manage/update/(:any)'] =" manage/manage/update/$1"; // (:any) sbsu2783
$route['manage/update/(:num)'] =" manage/manage/update/$1"; // (:num) 2783
$route['manage/update/(:any)/(:any)'] =" manage/manage/update/$1/$2"; // Just example
$route['manage/delete'] =" manage/manage/delete";
$route['manage/(:any)'] =" manage/manage/index/$1/$2"; // Not need most of the time
sitename.com/manage/edit/10
You may need to include the index.php or may not as not sure if you have configured your htaccess.
For example on controller site_url('manage/update') .'/'. $this->uri->segment(4);

If you are using HMVC then for calling function of Inner Controller does not require any routing. Just configure it correctly.
Second. name of your module and controller both are same. so when
you call
localhost/manage it redirects it to manage/manage/index by default but when you call
localhost/manage/update it try to find controller named update. so call like this
localhost/manage/manage/update

Related

Laravel resource route parameters not overriding

I am building a Laravel 8 api. I'm trying to set up a show route for /api/access-type/{access_type}. I want to change the {access_type} to be {id}
This is the route definition:
Route::middleware(['auth:api'])->group(function () {
/////////// not allowed to use these. Creating/deleting these resources would require code changes
Route::apiResource(
\App\Http\Controllers\AccessTypeController::$uri,
'AccessTypeController'
)->only(['index', 'show'])->parameters(['access_type' => 'id']);
});
When I look at the listed routes I can see that the route hasn't changed:
GET|HEAD | api/access-types/{access_type} | access-types.show | App\Http\Controllers\AccessTypeController#show | Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful | Illuminate\Routing\Middleware\ThrottleRequests:api | Illuminate\Routing\Middleware\SubstituteBindings | App\Http\Middleware\Authenticate:api
If I use postman to visit /api/access-types/3 I can see that there is no $request->id variable, but there is a $request->access_type variable, so the overwrite isn't working. What am I doing wrong? This should work according to: docs
I fixed it with the following:
Route::apiResource(
\App\Http\Controllers\AccessTypeController::$uri,
'AccessTypeController'
)->parameters(['access-types' => 'id']);
The parameter had to match the uri that I was setting it up for. I suppose this is so you can group multiple different resource routes into one.

Archiver v1.3.0 - Unable to zip directory content without the directory name being the root folder

I am using https://archiverjs.com/docs/ to zip a directory for my PhoneGap application but I have not yet managed to achieve what I want to.
I have a folder structured like this:
- www
- css
- images
- scripts
- config.xml
- index.html
Now what I would like to have is a zip file containing the the CONTENT of the www folder but NOT the www itself.
BAD
- www.zip
- www
- css
- images
- scripts
- config.xml
- index.html
GOOD
- www.zip
- css
- images
- scripts
- config.xml
- index.html
The code I have in place is the follow:
var archiver = require('archiver');
var output = fs.createWriteStream('./www/www.zip');
var archive = archiver('zip', {
store: true // Sets the compression method to STORE.
});
output.on('close', function() {
console.log(archive.pointer() + ' total bytes');
console.log('archiver has been finalized and the output file descriptor has closed.');
});
archive.on('error', function(err) {
throw err;
});
archive.pipe(output);
archive.directory('www/');
archive.finalize();
I have tried to add something like:
archive.directory('www/*');
but it throws an error.
Any other way I can accomplish that?
Thanks
I found the solution, I just needed to do the follow:
archive.directory('www', '/');
Problem solved :)
Thanks

How to set an image path in src attribute using vue 2

İs that possible to give an attribute like that?
src="${urlPath}/img/icon-{{flight.OperatingAirline._CompanyShortName}}.png"
doesn't works.
Use :v-bind (or shortcut ":") instead of "{{ }}" : v-bind
So :src="Any javascript here !"
:src="urlPath + '/img/icon-' + flight.OperatingAirline._CompanyShortName + '.png'"
urlPath and flight.OperatingAirline._CompanyShortName must be a javascript variable.
After edit #SLYcee's answer for JSTL combined solution:
:src="'${urlPath}/img/icon-' + flight.OperatingAirline._CompanyShortName + '.png'"

Redirect example.com/?p=25 to example.com/25 in CodeIgniter

I'm using CodeIgniter and I want to redirect links like this:
example.com/?p=25
to this:
example.com/25
How can this be achieved?
http://www.askaboutphp.com/58/codeigniter-mixing-segment-based-url-with-querystrings.html
or
to create url like this : http://yyyy.com/article/finishing-dan-snapshop-salkulator
add this code in routes.php
$route['article/(:any)'] = "article/readmore/$1";
description :
1. article : class name
2. readmore : method from class article
3. $1 : get value from uri segment 2 value
its .htaccess rewrite rule.make sure u have activated mod_rewrite .then put this line into website application root .htaccess file
RewriteRule ^/([0-9]+)/?$ p=$1 [NC,L] # Handle product
requests

Prefixing routes with locale in Symfony2

Here is my setup, a bit changed standard edition.
# app/config/routing.yml
_internal:
resource: "#AcmeDemoBundle/Controller/"
prefix: /{_locale}
requirements:
_locale: en|sr
And added /{_locale} in security.yml.
Routes before:
Name Method Pattern
_welcome ANY /
_demo_login ANY /demo/secured/login
_security_check ANY /demo/secured/login_check
_demo_logout ANY /demo/secured/logout
acme_demo_secured_hello ANY /demo/secured/hello
_demo_secured_hello ANY /demo/secured/hello/{name}
_demo_secured_hello_admin ANY /demo/secured/hello/admin/{name}
_demo ANY /demo/
_demo_hello ANY /demo/hello/{name}
_demo_contact ANY /demo/contact
_wdt ANY /_wdt/{token}
_profiler_search ANY /_profiler/search
_profiler_purge ANY /_profiler/purge
_profiler_import ANY /_profiler/import
_profiler_export ANY /_profiler/export/{token}.txt
_profiler_search_results ANY /_profiler/{token}/search/results
_profiler ANY /_profiler/{token}
_configurator_home ANY /_configurator/
_configurator_step ANY /_configurator/step/{index}
_configurator_final ANY /_configurator/final
Routes after:
Name Method Pattern
_welcome ANY /
_wdt ANY /_wdt/{token}
_profiler_search ANY /_profiler/search
_profiler_purge ANY /_profiler/purge
_profiler_import ANY /_profiler/import
_profiler_export ANY /_profiler/export/{token}.txt
_profiler_search_results ANY /_profiler/{token}/search/results
_profiler ANY /_profiler/{token}
_configurator_home ANY /_configurator/
_configurator_step ANY /_configurator/step/{index}
_configurator_final ANY /_configurator/final
_demo_login ANY /{_locale}/demo/secured/login
_security_check ANY /{_locale}/demo/secured/login_check
_demo_logout ANY /{_locale}/demo/secured/logout
acme_demo_secured_hello ANY /{_locale}/demo/secured/hello
_demo_secured_hello ANY /{_locale}/demo/secured/hello/{name}
_demo_secured_hello_admin ANY /{_locale}/demo/secured/hello/admin/{name}
_demo ANY /{_locale}/
_demo_hello ANY /{_locale}/hello/{name}
_demo_contact ANY /{_locale}/contact
Which ofc leads to No route found for "GET /en/demo/hello/World" for /en/demo/hello/World url.
Any idea how to fix this?
Additionally, I would like to implement per domain locale. I was trying https://github.com/schmittjoh/JMSI18nRoutingBundle, but for some reason it does not work with latest Symfony 2.0.9, at least for me. I was following the doc, but I got similar 404 error when trying prefixed urls.
Defining default values and requirements for placeholders in prefix is not possible in Symfony version 2.0.9. You'd have to upgrade to 2.1, which is currently in active development.

Resources