Skip to content

Instantly share code, notes, and snippets.

@cabloo
Last active December 8, 2016 20:56
Show Gist options
  • Save cabloo/32b23ce86c6b11ea8aa7 to your computer and use it in GitHub Desktop.
Save cabloo/32b23ce86c6b11ea8aa7 to your computer and use it in GitHub Desktop.
Add a root namespace (e.g. App) to a Laravel project that doesn't have one. Afterwards, set the namespace in phpspec.yml

Add a root namespace (e.g. App) to a Laravel project that doesn't have one.

([\s])([\\']{0,1})(Console|Events|Exceptions|Handlers|Helpers|Http|Models|Providers|Services)([\\;])

->

$1$2App\\$3$4

=====

([\s])"(Console|Events|Exceptions|Handlers|Helpers|Http|Models|Providers|Services)\\

->

$1"App\\\\$2\\

=====

\("(List|All|Models|Here)"\)

->

("$1")

=====

([\s])([\\']{0,1})(List|All|Models|Here);

->

$1$2App\\Models\\$3;

=====

Afterwards, set the namespace (in this case, App) in composer.json and phpspec.yml, e.g.

suites:
    main:
        namespace: App
        psr4_prefix: App
        src_path: app
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment