我正在尝试在Symfony 4上将FOS与HWIO集成。不幸的是,我遇到了如下所示的错误:
In FileLoader.php line 168:
A service definition must be an array or a string starting with "@" but string found for service "class" in D:\web-projects\pcrmanagement\config/services.yaml. Check your YAML syntax in D:\web-projects\pcrmanagement\config/services.yaml (which is loaded in resource "D:\web-projects\pcrmanagement\config/services.yaml").
In YamlFileLoader.php line 336:
A service definition must be an array or a string starting with "@" but string found for service "class" in D:\web-projects\pcrmanagement\config/services.yaml. Check your YAML syntax.
下面是我的代码,我将仅发布您需要查看的内容,如果您需要更多代码进行审查,我可以添加更多内容。
#config/hwi_oauth.yaml
hwi_oauth:
firewall_names: [main]
fosub:
username_iterations: 30
properties:
googleplus: username
resource_owners:
google:
type: google
client_id: secret
client_secret: secret
scope: "email profile"
options:
csrf: true
# security.yaml
providers:
in_memory: { memory: ~ }
fos_userbundle:
id: fos_user.user_provider.username
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
main:
pattern: ^/
form_login:
provider: fos_userbundle
csrf_token_generator: security.csrf.token_manager
oauth:
resource_owners:
facebook: "/login/check-facebook"
google: "/login/check-google"
my_custom_provider: "/login/check-custom"
my_github: "/login/check-github"
login_path: /login
use_forward: false
failure_path: /login
oauth_user_provider:
service: my.oauth_aware.user_provider.service
logout: true
anonymous: true
#services.yaml
my.oauth_aware.user_provider.service:
class: HWI\Bundle\OAuthBundle\Security\Core\User\FOSUBUserProvider
arguments: ['@fos_user.user_manager',{google: username}]
我认为他如何读取services.yaml中的参数存在问题
答案 0 :(得分:0)
创建自定义user_provider并扩展HWI\Bundle\OAuthBundle\Security\Core\User\FOSUBUserProvider
。
然后配置您的自定义提供程序:
services:
App\Security\Core\User\MyFOSUBUserProvider:
arguments: ['@fos_user.user_manager', { facebook: facebook_id }]
然后更改:
oauth_user_provider:
service: MyBundle\Security\Core\User\MyFOSUBUserProvider