silexphp / Silex

[DEPRECATED -- Use Symfony instead] The PHP micro-framework based on the Symfony Components
https://silex.symfony.com
MIT License
3.58k stars 718 forks source link

Class 'Symfony\Component\Validator\Constraints' not found #1128

Closed ghost closed 9 years ago

ghost commented 9 years ago

Using Silex - added the following into composer.json

"require": { "silex/silex": "~1.2", "symfony/security": "~2.6", "doctrine/dbal": "~2.2", "symfony/validator": "~2.6" },

From the documentation: http://silex.sensiolabs.org/doc/providers/validator.html

use Symfony\Component\Validator\Constraints as Assert;

I get Fatal error: Class 'Symfony\Component\Validator\Constraints' not found

The class does not exist in /vendor/symfony/validator/Symfony/Component/Validator.

I did composer update before attempting to use this.

Please assist.

henrikbjorn commented 9 years ago

You are not writing all of what you do, and you need to read up on namespacing and how aliasing namespaces works in php.

This is not a Silex issue.

henrikbjorn commented 9 years ago

http://php.net/manual/en/language.namespaces.importing.php

nunocodex commented 9 years ago

Crimson not escape from your fault... learn from other messages and happy coding ^_^