1

I am trying to learn Symfony 2. I'm trying to follow the example in the Symfony book (Page 17). I have downloaded and unpacked Symfony in my working directory.

The absolute path to the file I'm trying to use is in: symfony\vendor\symfony\symfony\src\Symfony\Component\HttpFoundation\Request.php

However following the books example closely, I just put:

use Symfony\Component\HttpFoundation\Request

Either way, both these approaches did not work for me.

Using the books approach I'm getting the following error:

Fatal error: Class 'Symfony\Component\HttpFoundation\Request' not found in C:/...

Using my approach with the longer path, I'm still getting this error, when I use include to navigate to the long path, the file is found but I'm getting some other error (just wanted to verify I'm able to get to the file, which I am).

I appreciate any advice in overcoming this problem. Many thanks in advance!

2 Answers 2

4

in PHP use statement requires Fully Qualified Class Name, not directory. So use Symfony\Component\HttpFoundation\Request is just fine.

If you decided to try these "examples" you will have to require autoload.php file first. It is located in your vendors directory.

So if you make file named "myfile" in symfony web folder it should start like this:

<?php

require '../vendor/autoload.php';

use Symfony\Component\HttpFoundation\Request;

$request = Request::createFromGlobals();
Sign up to request clarification or add additional context in comments.

6 Comments

+1, Thank you for the reply. How come Symfony doesn't load autoload.php in their example?
Well, those aren't really representative "examples". It's just introduction to the story. You will probably never write that code yourself because it's already written for you (see app.php and app_dev.php files in web) directory.
I see. Thanks for the help... what would be a good way to study Symfony if not follow the examples closely?
Ugh....tough one. Probably varies on your experience in general programming, PHP, and understanding of MVC. When I started learning it I just read book a few times. One thing to keep in mind though is that it has pretty steep learning curve, but documentation is great so don't give up and it will all start to come together sooner or later.
I have a good understanding of general and OOP PHP but am new to frameworks and MVC.
|
0
Run - > composer update
Run the Path -> ./vendor/bin/upgrade-carbon

Then Will fixed this issue in laravel

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.