2

I'm trying to get Symfony in my Mac, so I installed symfony and composer in order to start developing, but when I create the project I have some problems:

composer create-project symfony/skeleton cost_management
Installing symfony/skeleton (v4.0.5)
  - Installing symfony/skeleton (v4.0.5): Loading from cache
Created project in cost_management
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 21 installs, 0 updates, 0 removals
  - Installing symfony/flex (v1.0.71): Loading from cache
  - Installing symfony/polyfill-mbstring (v1.7.0): Loading from cache
  - Installing symfony/console (v4.0.6): Loading from cache
  - Installing symfony/routing (v4.0.6): Loading from cache
  - Installing symfony/http-foundation (v4.0.6): Loading from cache
  - Installing symfony/yaml (v4.0.6): Loading from cache
  - Installing symfony/framework-bundle (v4.0.6): Loading from cache
  - Installing symfony/http-kernel (v4.0.6): Loading from cache
  - Installing symfony/event-dispatcher (v4.0.6): Loading from cache
  - Installing psr/log (1.0.2): Loading from cache
  - Installing symfony/debug (v4.0.6): Loading from cache
  - Installing symfony/finder (v4.0.6): Loading from cache
  - Installing symfony/filesystem (v4.0.6): Loading from cache
  - Installing psr/container (1.0.0): Loading from cache
  - Installing symfony/dependency-injection (v4.0.6): Loading from cache
  - Installing symfony/config (v4.0.6): Loading from cache
  - Installing psr/simple-cache (1.0.1): Loading from cache
  - Installing psr/cache (1.0.1): Loading from cache
  - Installing symfony/cache (v4.0.6): Loading from cache
  - Installing symfony/dotenv (v4.0.6): Loading from cache
Writing lock file
Generating autoload files
Symfony operations: 4 recipes (7c280e93acfad83db0b06dac8600cc2d)
  - Configuring symfony/flex (>=1.0): From github.com/symfony/recipes:master
  - Configuring symfony/framework-bundle (>=3.3): From github.com/symfony/recipes:master
  - Configuring symfony/console (>=3.3): From github.com/symfony/recipes:master
  - Configuring symfony/routing (>=4.0): From github.com/symfony/recipes:master
Executing script cache:clear [KO]
 [KO]
Script cache:clear returned with error code 255
!!  
!!  Fatal error: Uncaught Symfony\Component\Debug\Exception\ClassNotFoundException: Attempted to load class "FileResource" from namespace "App".
!!  Did you forget a "use" statement for "Symfony\Component\Config\Resource\FileResource"? in /Users/gate11/Desktop/cost_management/src/Kernel.php:39
!!  Stack trace:
!!  #0 /Users/gate11/Desktop/cost_management/vendor/symfony/framework-bundle/Kernel/MicroKernelTrait.php(80): App\Kernel->configureContainer(Object(Symfony\Component\DependencyInjection\ContainerBuilder), Object(Symfony\Component\Config\Loader\DelegatingLoader))
!!  #1 [internal function]: App\Kernel->Symfony\Bundle\FrameworkBundle\Kernel\{closure}(Object(Symfony\Component\DependencyInjection\ContainerBuilder))
!!  #2 /Users/gate11/Desktop/cost_management/vendor/symfony/dependency-injection/Loader/ClosureLoader.php(38): call_user_func(Object(Closure), Object(Symfony\Component\DependencyInjection\ContainerBuilder))
!!  #3 /Users/gate11/Desktop/cost_management/vendor/symfony/config/Loader/DelegatingLoader.php(40): Symfony\Component\DependencyInj in /Users/gate11/Desktop/cost_management/src/Kernel.php on line 39
!!  PHP Fatal error:  Uncaught Symfony\Component\Debug\Exception\ClassNotFoundException: Attempted to load class "FileResource" from namespace "App".
!!  Did you forget a "use" statement for "Symfony\Component\Config\Resource\FileResource"? in /Users/gate11/Desktop/cost_management/src/Kernel.php:39
!!  Stack trace:
!!  #0 /Users/gate11/Desktop/cost_management/vendor/symfony/framework-bundle/Kernel/MicroKernelTrait.php(80): App\Kernel->configureContainer(Object(Symfony\Component\DependencyInjection\ContainerBuilder), Object(Symfony\Component\Config\Loader\DelegatingLoader))
!!  #1 [internal function]: App\Kernel->Symfony\Bundle\FrameworkBundle\Kernel\{closure}(Object(Symfony\Component\DependencyInjection\ContainerBuilder))
!!  #2 /Users/gate11/Desktop/cost_management/vendor/symfony/dependency-injection/Loader/ClosureLoader.php(38): call_user_func(Object(Closure), Object(Symfony\Component\DependencyInjection\ContainerBuilder))
!!  #3 /Users/gate11/Desktop/cost_management/vendor/symfony/config/Loader/DelegatingLoader.php(40): Symfony\Component\DependencyInj in /Users/gate11/Desktop/cost_management/src/Kernel.php on line 39
!!  

I tried many ways to install it, I saw the commands in their website, so I did it but still having some problems installing it. If someone knows what's wrong with it, or if I need something else, I'm hoping for your help. Thanks.

Stephan Vierkant
  • 9,674
  • 8
  • 61
  • 97
Dev web
  • 81
  • 1
  • 13
  • Which PHP version are you using?! If you're not using PHP 7.1, then you can't use Symfony 4 yet, nor can you use the new skeleton... Install the [Symfony instaler](https://symfony.com/doc/3.4/setup.html) and use it to make a new project with the command `symfony new my_project 3.4` – Preciel Mar 13 '18 at 23:45
  • There was a bug checked in a few hours ago. https://github.com/symfony/recipes/pull/380 It is being worked on. Monitor the issue then try again. – Cerad Mar 14 '18 at 00:09
  • I'm using php 7.1.14n I think there was a bug because I don't get the problem here. – Dev web Mar 14 '18 at 07:50
  • @Preciel I can't use symfony without using composer [RuntimeException] The Symfony Installer is not compatible with Symfony 4.x or newer versions. Run this other command to install Symfony using Composer instead: composer create-project symfony/skeleton cost – Dev web Mar 14 '18 at 08:18
  • In case anybody is wondering, the issue has been solved and create-project is now working again. – Cerad Mar 14 '18 at 13:12

2 Answers2

2

Please replace composer create-project symfony/skeleton cost_management with composer create-project symfony/website-skeleton cost_management

            **OR**

You could install and setup Symfony4 application on Ubuntu with PHP7.2 by these steps execute through temminal:

  1. composer create-project symfony/website-skeleton cost_management
  2. cd cost_management
  3. php -S 127.0.0.1:8000 -t public
  4. ctrl + c to exit server run composer install
  5. sudo chmod 777 -R var/cache/ var/log/
  6. now again php -S 127.0.0.1:8000 -t public
  7. Now you can check on your browser by this http://localhost:8000/ or directly you can access without server run by http://localhost/project_directory/public/index.php

Note:- 1. By default symfony 4 is set to dev environment, but you could set your environment by setting $_SERVER['APP_ENV'] 2. If it's working proper then you will see a 404 error message and profiler in bottom because it's by default set to dev mode. 3. To see something you need to create your first controller by following documents Symfony 4 create your first page

Ashutosh Rai
  • 458
  • 1
  • 7
  • 14
0

Just add this:

use Symfony\Component\Config\Resource\FileResource;

to the top of your src/Kernel.php, it was missed for some reason.

After that, you can continue with composer install

Victor Fedorenko
  • 331
  • 2
  • 13
  • I added it, the project was created, but when I start the http://127.0.0.1:8000, I have this errors: Notice: Undefined index: APP_DEBUG in /Applications/MAMP/htdocs/cost_management/public/index.php on line 19 /Applications/MAMP/htdocs/cost_management/vendor/symfony/http-kernel/EventListener/RouterListener.php on line 144 – Dev web Mar 14 '18 at 08:15