Created controller and tried to access it by url got an error like 404 Error
The page you are looking for could not be found.
Try checking the URL for errors, then hit the refresh button on your browser.
Used the fallowing procedure
//created route
'app-test-index' => array(
'test',
array(
'controller' => 'test',
'action' => 'index',
),
),
//controller
namespace App\Controller;
use Ppb\Controller\Action\AbstractAction,
Cube\Controller\Front,
Cube\View,
Cube\Validate\Url as UrlValidator,
Cube\Controller\Request,
Ppb\Service;
class Test extends AbstractAction
{
public function Index()
{
die('ok');
}
public function test()
{
die('ok');
}
}
How to create model view controller in PHPProbid
how to customize PHPProbid
Thanks
How to create a controller in PHPPROBID version 7.8
Step 1: Create a controller file in corresponding module
step 2: Edit the model Acl file in corresponding module
for example
a) Create a controller Test.php in module/App/src/App/Controller.
b) Add resources (Give permissions to user roles for the created controller) in
module/App/src/App/Model/Acl.php file
In our case you need to add the following lines
$test = new Permissions\Resource('Test');
$this->addResource($test);
$this->allow('Guest', 'Test');
It is important to note that the module/App/src/App/Model/Acl.php file will be replaced during phpprobid update
so you need to create a folder named mods in root(IF already exist no need to create).
Copy the file to mods folder with corresponding folder structure
In our example copy Acl.php to mods/module/App/src/App/Model folder.
Now you can access your controller
http://your_domain.com/index.php?module=app&controller=test&action=index
Related
I want to change views folder of yii2 to structure bellow
views
----default
----site
----index.php
----error.php
----login.php
In the siteController i'm using code bellow
public function actionIndex(){
return $this->render('default/index');
}
and error
The view file does not exist: D:\wamp\www\yii2\backend\views\site\default/index.php
Please help me
With your current code, the Site Controller search the view file under his view's folder /views/site, you need to get the right path:
$this->render('../default/site/index');
I suggest to create an alias for be more flexible, like #default_views in your main-local file:
'aliases' => [
'#default_views' => '../default/',
So, the function:
public function actionIndex(){
return $this->render(Yii::getAlias('#default_views') . 'site/index');
}
I have some website http://www.example.com, I have a controller abc in which I have method index() which loads my website's view. I have made my controller abc as default controller so that when user enters example.com , he can directly see the view. I cannot change this default controller in any case. Now I want that if user enters example.com/1234 , where 1234 is profile number, so it should show that profile . if it is example.com/5678 , then it should show 5678's profile. The problem I am facing is , if user enters example.com/1234 then it will throw a 404 error because I don't have any controller 1234, even if I make a check in my default controller's index function if($this->uri->segment(3) == True) it is throwing 404 error. Any help would be appreciated.
In your routes file add this change:
$route['(:any)'] = 'abc/index/$1';
Then in abc controller:
public function index($profile=NULL)
{
$profile = $this->uri->segment(1, 0);
echo($profile);// just for checking, of course, you will remove this later, + the rest of your code, related to user id
Typically there is a one-to-one relationship between a URL string and its corresponding controller class/method.
In the routes.php (config folder) you can change the defoult controller and routing also. Read the Wildcards (secion) in documentation below
More informacion read the documentation
Create a pre_controller hook in config/hooks.php. Remember to enable hooks in config/config.php if you haven't already.
Example:
$hook['pre_controller'][] = array(
'class' => 'Thehook',
'function' => 'check_for_profile',
'filename' => 'thehook.php',
'filepath' => 'hooks'
);
Then create your hook method check_for_profile() in hooks/thehook.php. This method can check for a matching profile and display or redirect accordingly. If no profile match is found you can call the show_404() method.
This way, your existing controller/method paths are unaffected, and all of your routes remain intact.
If you're redirecting within the hook, use this format:
header("Location: controller/method");
..rather than
redirect('controller/method');
...as the latter will result in a continuous loop
Add in routes.php
$route["(.*)"] = 'abc/userid/$1';
Then in main controller abc add
public function userid()
{
$userid=$this->uri->segment(1);
echo ($userid);
}
Now you have userid in this function :)
I have built admin of my cakephp site using prefix 'webadmin'. Now I need to change this to something like 'aRRT6nnf'.
I changed the admin prefix in core.php, routes.php and even changes the filenames in views folder but this gives the following error:
Error: The requested address '/aRRT6nnf' was not found on this server.
I made following changes to accomplish this:
//core.php
Configure::write('Routing.prefixes', array('aRRT6nnf'));
//routes.php
Router::connect('/aRRT6nnf', array('controller' => 'dashboard', 'action' => 'index', 'prefix'=>'aRRT6nnf', 'aRRT6nnf'=>true));
Any help would be appreciated.
Have you changed the prefixes on your controller methods
When using admin routing in Cake 1.3 your controller actions need to be prefixed with the route they pertain to for example take route admin your Dashboard controller should be something like this
class DashboardController extends AppController
{
public admin_index() {
}
So in your specific case you would need to change them to
public aRRT6nnf_index() {
}
I'm new to FuelPHP and I did a little coding with it! What I did was create a simple controller and created two methods. One for action_index() and the other is action_add().
the code is given below. Views are already in the app\views\ folder.
class Controller_Student extends Controller
{
public function action_index()
{
return Response::forge(View::forge('index'));
}
public function action_add()
{
return Response::forge(View::forge('select'));
}
}
I've set the root to this controller class. When I run the application the index works fine and loads the directed view. But when I give the following URL
http://localhost/project/public/add/
the method doesn't get called! A 404 error is give saying
You can see this page because the URL you are accessing cannot be found.
What Am I doing wrong here. I've gone through every documentation, tutorial I find but I shouldn't get this type of an error. Please help me.
Below is the routing file code :
return array(
'_root_' => 'student', // The default route
'_404_' => 'welcome/404', // The main 404 route
);
You've set the root to student controller, but that doesn't mean all traffic goes through that controller. Try visiting:
http://localhost/project/public/student/add/
I have a controller file with the two actions i.e :
class IndexController extends Zend_Controller_Action
{
public function init()
{
/* Initialize action controller here */
}
public function indexAction()
{
// action body
}
public function doLoginAction()
{
// action body
}
}
and their corresponding view files.
i.e when i hit http://www.mydomain.com/index it loads the index view.
The problem I am facing is that when I try to access the index action of this controller it will load the corresponding view but when I try to hit the dologin action it gives the
error
http://www.mydomain.com/index/dologin
*Message: Action "dologin" does not exist and was not trapped in __call()*
Request Parameters:
array (
'controller' => 'index',
'action' => 'dologin',
'module' => 'default',
)
same is happening when I try it with another controller and action. The index action runs fine for that controller too but not any other action in the controller.
P.S : I have configured mod_rewrite module and AllowOverride ALL in apache config file
Camel-cased action names are expected to be dashed as params. Therefore, doLoginAction() will respond to /default/index/do-login, not dologin. If you wish the URL to be dologin, you should rename the action to dologinAction().
You can have hyphen(-) separated urls at controller level also.
Suppose you need a url like this:
http://www.mydomain.com/do-some-stuff/my-stuff/
Then your controller should be named as:
DoSomeStuffController (as class name) && DoSomeStuffController.php (as controller file name)
and
myStuffAction() (as your method name)