4

I developed a website using Symfony2. Unfortunately, the website was deleted on the hard disk and I lost all my work.

However, I have succeed to recover my project sources folder (the one that was in www folder of Wampserver) thanks to a files recovery software called "EaseUS Data Recovery Wizard".

I have installed Wampserver 2.5 and I have put the folder that I have restored in the www folder of Wampserver. The problem is that whenever I try to access to the home page of my website, I see the error message below:

Fatal error: Class 'Composer\Autoload\ClassLoader' not found in C:\wamp\www\Wkayet_project\PFESymfony2\vendor\composer\autoload_real.php on line 23

I really wonder why I get such an error message although I put the right URL address! So, my question is: how can I tackle this problem?

This is the content of the composer.json file that I have:

    {
    "name": "symfony/framework-standard-edition",
    "license": "MIT",
    "type": "project",
    "description": "The \"Symfony Standard Edition\" distribution",
    "autoload": {
        "psr-0": { "": "src/" }
    },
    "require": {
        "php": ">=5.3.3",
        "symfony/symfony": "~2.4",
        "doctrine/orm": "~2.2,>=2.2.3",
        "doctrine/doctrine-bundle": "~1.2",
        "twig/extensions": "~1.0",
        "symfony/assetic-bundle": "~2.3",
        "symfony/swiftmailer-bundle": "~2.3",
        "symfony/monolog-bundle": "~2.4",
        "sensio/distribution-bundle": "~2.3",
        "sensio/framework-extra-bundle": "~3.0",
        "sensio/generator-bundle": "~2.3",
        "incenteev/composer-parameter-handler": "~2.0"
    },
    "scripts": {
        "post-install-cmd": [
            "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile"
        ],
        "post-update-cmd": [
            "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile"
        ]
    },
    "config": {
        "bin-dir": "bin"
    },
    "extra": {
        "symfony-app-dir": "app",
        "symfony-web-dir": "web",
        "incenteev-parameters": {
            "file": "app/config/parameters.yml"
        },
        "branch-alias": {
            "dev-master": "2.4-dev"
        }
    }
}

Edit2

When I run this command: composer install , I get what is below on my screen:

[Seld\JsonLint\ParsingException]
"./composer.lock" does not contain valid JSON 
Parse error on line 1:
Expected one of: 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '['

When I run this command: composer --version , I get what is below on my screen:

Composer version 1.0-dev <f85d965732d9505b69242a070dc0b381c9f6bbab> 2015-10-19 10:04:38

When I run this command: composer diagnose , I get what is below on my screen:

Checking composer.json: FAIL
Defining autoload.psr-0 with an empty namespace prefix is a bad idea for performance
Checking platform settings: FAIL
The xdebug extention is loaded, this can slow down Composer a little.
Disabling it when using Composer is recommended.
Checking git settings: OK
Checking http connectivity to packagist: OK
Checking https connectivity to packagist: OK
Checking github.com rate limit: OK
Checking disk free space: OK
Checking composer version: OK
k0pernikus
  • 60,309
  • 67
  • 216
  • 347
Nadim2014
  • 105
  • 2
  • 10
  • Maybe you need to run composer install to recreate the autoload files – Carlos Granados Oct 21 '15 at 11:54
  • Also, could you show us your `composer.json`? – Tomas Votruba Oct 21 '15 at 12:06
  • @CarlosGranados : I did run the composer install after downloading Composer-Setup.exe from this link: https://getcomposer.org/download/ . However, I still see the same error message! – Nadim2014 Oct 21 '15 at 14:36
  • @TomášVotruba: I have added the content of the composer.json file that I have in my question. You can check that out in the edit section that I have added. Thanks in advance. – Nadim2014 Oct 21 '15 at 14:43
  • please run these 3 commands and update you question with results. **1: `composer install`** ; **2: `composer --version`** **3: `composer diagnose`** – nakashu Oct 21 '15 at 21:15
  • @nakashu: I have added the results of each command you mentioned in the "Edit2" section in my question. Please have a look at them. Thanks in advance. – Nadim2014 Oct 22 '15 at 15:15
  • @Nadim2014 also please remove senteces from the begining of your question about how you recoverd your data and with what software, its not important for the problem at all. Simple *"I run symfony2 app on wampserver - windows and I got this after running composer"* would be enough. – nakashu Oct 22 '15 at 16:27

2 Answers2

4

Based on this output:

[Seld\JsonLint\ParsingException]
"./composer.lock" does not contain valid JSON 
Parse error on line 1:
Expected one of: 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '['

it seems you have some syntax error in your composer.lock file, which block composer install to end successfully and generating autoload files.

The easy fix would be to delete composer.lock file, and then run composer install again in your console. This will generate a new lock file with most up to date dependencies, as per your configuration in your composer.json

safer fix at least if you really need the exact dependencies as there are in your composer.lock would be to open a fix the syntax error there. If you need help post the contents here.

Also it would be probably neccesary to clear the cache, either by running php app/console cache:clear or by manualy deleting cache files in /app/cache/*

nakashu
  • 1,058
  • 12
  • 21
  • Well, I deleted the composer.lock file then I ran `composer.lock`, but I got this error message: ContextErrorException: Notice: unserialize(): Error at offset 0 of 20109 bytes in C:\wamp\www\Wkayet_project\PFESymfony2\vendor\symfony\symfony\src\Symfony\Component\ClassLoader\ClassCollectionLoader.php line 71 – Nadim2014 Oct 22 '15 at 18:51
  • Do you have any idea about how to tackle that? – Nadim2014 Oct 22 '15 at 18:51
  • @Nadim2014 you deleted the `composer.LOCK` and run `composer.LOCK`? I wrote after deleting the lock file you should run `composer INSTALL` – nakashu Oct 22 '15 at 19:33
  • I'm sorry, I meant I deleted the composer.lock file then I ran `composer install` (it was just a typing error I have committed while typing my comment :) ) – Nadim2014 Oct 23 '15 at 13:45
  • @Nadim2014 you got the unserialize error after running composer install or after trying to reload your page? What was the output of composer install. And also try to clear your cache that could fix that error. edited my answer cache clearing – nakashu Oct 23 '15 at 21:35
  • I've resolved it! I just deleted all the folders under the vendor folder except the autoload.php file, then under my project folder I ran this command: `composer update`...And it worked! – Nadim2014 Oct 26 '15 at 10:01
0

I just deleted all the folders under the vendor folder except the autoload.php file, then under my project folder I ran this command:

composer update

and it worked.

k0pernikus
  • 60,309
  • 67
  • 216
  • 347
Nadim2014
  • 105
  • 2
  • 10
  • You could have deleted all the content of your `vendor` direcotory, so keeping the `autoload.php` around doesn't do much (nor does it harm, as it may get overwritten anyway by the update). Most likely fix was running the update, as that generates a new `composer.lock`. Be aware though that all you dependencies are now updated, and could in theory have introduced breaking changes, so check you app carefully. The `composer.lock` is there for that very reason, to ensure you can always deploy a known working state of your application. – k0pernikus Oct 26 '15 at 10:13
  • @k0pernikus: ok, I'll keep that in mind and I'll try my app at any rate. – Nadim2014 Oct 26 '15 at 10:19