Reputation: 181
I am a beginner in symfony framework and I want to run my function Which I
Created in BlogController
<?php
namespace AppBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
class BlogController extends Controller
{
/**
* @Route("/blog")
*/
public function showAction()
{
echo "hello friend";
}
}
?>
C:\xampp\htdocs\mysymfony\src\AppBundle\Controller
mysymfony is project name.
Here is my routing.yml
app:
resource: "@AppBundle/Controller/"
type: annotation
When I hit URL:-
http://localhost/mysymfony/blog
I get this Error
**
Object not found!
The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again.
If you think this is a server error, please contact the webmaster.
Error 404
localhost
Apache/2.4.12 (Win32) OpenSSL/1.0.1l PHP/5.6.8
**
I don't know how structure of URL to run BLOG function.Please resolved this problem
Upvotes: 2
Views: 3480
Reputation:
This is most likely because you run your url in the root directory.
With your Controller you'll need to run http://localhost/mysymfony/web/app_dev.php/blog
for the development environment or http://localhost/mysymfony/web/app.php/blog
for the production environment.
Or configure your Apache to run directly to web/
. You can find that guide here.
Upvotes: 3