I'm trying to run a controller action from command line. The php code is written in Kohana 3.3. Kohana officially says I have to use minion task processor. How do I include my action in this module?
You can call the minion controller from command line like this (as of Kohana 3.3):
$ php index.php --uri=minion --task={task}
Every task goes inside classes/task, as explained here https://github.com/kohana/minion#writing-your-own-tasks
Make sure to enable the minion module in the bootstrap
Before the minion module, you'd have to use controllers, and some server related stuff would be unavailable, but you would do as in the browser
$ php index.php --uri="control/do/action"
Related
i want to use Requests for PHP in my yii project.
I installed the yii2 basic template, and copied the Requests Class File (and the Requests directory) to root/vendor.
I include the requests.php file with this line
include('../vendor/Requests.php');
But i always get an error that yii cant find the requests.php class.
What i need to do to implement the requests class?
Use Composer, as proposed in project README. Run this command in root of your project:
composer require rmccue/requests
I am working on a project in php Phalcon.
I am working with the Xampp server. The installation process that I followed is on this link:
http://docs.phalconphp.com/en/latest/reference/install.html
I am following the documentation on the website as guide and tutorial.
My problem is, every time I type "class MyClass extends \Phalcon\Mvc\Model"
it says undefined namespace "Mvc" and in other files it also gives error that Phalcon is an undefined namespace.
The installation seems okay.
Please help me out.
I think this is not really a problem with the installation of Phalcon.
I have recognized the same behaviour of my IDE because Phalcon is only loaded as an extension of PHP and not available as real PHP files which can be indexed by your IDE.
The easiest way to check if install was ok is to create a info.php in your project root.
<?php
phpinfo();
If you open this file in browser it should show a block with information about phalcon.
There is a script that creates stub files for you that can be integrated in you project.
https://github.com/phalcon/phalcon-devtools/blob/master/ide/gen-stubs.php
If these files are indexed by your IDE, the message of Undefined namespace should be gone.
If your code works. And IDE shows Mvc undefined namespace then you have to install Phalcon developer tool plugin for your IDE. the plugin is available for PHPStorm. Phalcon is a C extention and for this if you not install developer tool plugin then IDE will show undefined namespace.
Phalcon has different ways to use model like register model class, register namespace or register dir. If you create the model by command rather than manually write code you will get the proper base model class to extend. If still problem then there is problem with Phalcon installation.
Use --namespace="" for model:
phalcon create-model profiles --namespace="Application\Models"
For scaffold:
phalcon create-scaffold profiles --ns-models="Application\Models" --ns-controllers="Application\Controllers"
If you do not register the model namespace and register only model directory then edit the model file after creation and remove the namespace definition.
first check if php load phalcon module. for that in terminal type
php -r "echo phpinfo();" | grep 'phalcon'
if everything went write you should see line
phalcon => enabled
in windows grep wont work and you should look for that line yourself.
I have tried almost everything that was there in the previous answers
Command: /usr/local/bin/php /home/username/public_html/temp/index.php/ controller function
This is the command I am using as my site is inside the temp folder of the particular domain
Earlier there were errors of 404 but now it shows
Could not open input file: /home/username/public_html/temp/index.php/
Any idea of the solution?
I cannot actually remember how CodeIgniter does its first step of routing - but I firmly believe it uses a rewrite rule to do it. As such, if you want to use codeIgniter's routing, you'll need to go through Apache/nginx. Sorry.
A good call would be wget -q http://whatever.your.site.is/index.php/controller/function, though.
just remove the slash at the end so it shows like this
/usr/local/bin/php /home/username/public_html/temp/index.php controller function
I'm trying out codeIgniter and the Modular Extension. So far I followed the installation instructions from wiredesignz on bitbucket. Now I'm trying the tutorial HMVC: an Introduction and Application from NetTuts.
I'm doing this with the actual version of CodeIgniter 2.1 and the actual version of the Modular Extension (downloaded the .zip version from bitbucket).
All works fine until I'm trying to run a method from a controller of another module.
The setup in short is, that there's two modules (site & login). Within the site's controllers there's site.php (/modules/site/controllers/site.php) with a method that checks if a user is logged in. This method would exit the script execution if accessing the site without being logged in. As this method logically belongs to the login module, the author suggests moving it there. So it then is moved to /modules/login/controllers/login.php.
The problem now is, how to access the method of the login module from within the site module. The slightly adjusted code from the tutorial:
// modules/site/controllers/site.php
function __construct()
{
// parent::Controller();
// replaced with:
parent::__construct();
// modules::run('login/is_logged_in');
// replaces with:
$this->load->module('login')->is_logged_in();
}
Like this I'm getting an error:
Unable to load the requested file: logged_in_area.php
The method in question is inside the site module as well:
// modules/site/controllers/site.php
function members_area()
{
$this->load->view('logged_in_area');
}
The Script executes right until the load->view line and produces the error. There's no problem accessing the logged_in_area.php with running the is_logged_in method from within the site controller with the line:
$this->is_logged_in();
Any ideas?
edit:
the application tree:
/application
/...
/modules
/login
/controllers
login.php
/models
/views
login_form.php
signup_form.php
signup_successful.php
/site
/controllers
site.php
/models
membership_model.php
/views
logged_in_area.php
PS: How can I get more INformation about the error? CodeIgniter seems to be very reserved about error output ...
As stated in the documentation here to load a view from within another module, you need to use an extended MX controller and a method:
<?php echo Modules::run('module/controller/method', $param, $...); ?>
I am new to Zend Framework, and i am attempting to remove an action using ZF command line tools. However, i am not able to do so. Basically, there's a function to an action in my controller that i wish to remove. I created the action using the following command:
Action
zf create action name controller-name[=Index] view-included[=1] module
Is there a command to remove it?
There is no command in Zend_Tool for that. You need to do that manually, by removing the action method in the controller and deleting the view script. You have also to edit the .zfproject.xml in the root of your project.
If you remove any controller or action manually, you have to also edit .zfproject.xml file on the root of your project, otherwise it will not allow you to create that controller or action in future again with zend tool.
Go to your application root and edit .zfproject.xml file. This is the file, where zf command will create each controller and action log. remove those actions from there and from controller files and also the views.