Beginning Kohana/php with PhpStorm
I'm coming from Asp.Net MVC 3 and I'm trying to learn to use Kohana and php, using PhpStorm as IDE.
I really am a beginnner in php, but I want to learn it using Kohana to get my feet wet as quickly as possible with something similar to Asp.Net MVC (i.e. an MVC framework).
But I don't understand how to get PhpStorm to run the project. I have created a simple controller called "home.php", with this extremely simple test class:
class Controller_Home extends Controller {
public function action_index()
{
echo 'Hello World!';
}
}
I changed the routing in bootstrap.php (which I really don't know what it does and where it's called, but I found the routing in there) to this:
Route::set('default', '(<controller>(/<action>(/<id>)))')
->defaults(array(
'controller' => 'home',
'action' => 'index',
));
Now, I can run this fine by going to http://localhost/kohana
But, I have no idea how to run it from within PhpStorm. I want to be able to run projects in Kohana just like I do in Visual Studio with Asp.Net MVC projects. So how do I tell PhpStorm how开发者_如何学JAVA to run this?
I get an error message if I try to run home.php, saying it's not "specified". And in any case it doesn't seem right to specify a particular file at all, since it is to be run through the controllers specified in the routing. So how do I configure it?
Sorry if this is a stupid question, remember I am new to php and Kohana, but I think I've been pampered quite a bit in Visual Studio, where I really don't have to think about these things at all, so I probably don't understand the inner workings very well. I'd appreciate a simple explanation of what I need to do and why.
I figured it out, I think... Perhaps this is very obvious to everyone who is not such a php novice as me, but I'll write it up here anyway in case it helps anyone:
What I needed to do was to go into Run > Edit configurations, and create a new Web Application, select my localhost server and the root folder (in my case http://localhost/kohana). Then when I choose to run this application it runs the default index.php in the root folder, and because of the default routing I set in bootstrap.php (see question above) the home controller index action is called and run.
精彩评论