ide.json


Overview

Starting from 4.1.1 version Laravel Idea allows to highly customize completions, view paths, and blade component sources by adding a special ide.json file to the project. This can be super useful for Laravel package creators.


Example ide.json:

{
    "$schema": "http://laravel-ide.com/schema/laravel-ide-v1.json",
    "completion": {
        "route": [
            {
                "methods": ["routeForTenant"],
                "functions": ["customRouteFunction"],
                "parameters": [1]
            },
            {
                "functions": ["anotherRoute"]
            }
        ],
        "routeAction": [
            {
                "methods": ["actionForTenant"],
                "classes": ["Tenant"],
                "parameters": [1]
            }
        ],
        "config": [
            {
                "functions": ["customConfig"],
                "parameters": [1]
            },
            {
                "functions": ["storageFunc"],
                "parameters": [1],
                "prefix": "filesystems.disks"
            }
        ],
        "translation": [
            {
                "functions": ["customTrans"],
                "parameters": [1]
            }
        ],
        "view": [
            {
                "functions": ["customView"],
                "parameters": [1]
            }
        ]
    },
    "view": {
        "paths": [
            {
                "path": "test/views",
                "namespace": "test"
            }
        ]
    },
    "blade": {
        "components": {
            "viewPaths": [
                {
                    "path": "directory/with/blade/component/views",
                    "namespace": "namespace"
                },
                {
                    "path": "resources/views/components",
                    "namespace": "",
                    "prefix": "jet-",
                    "viewNamespace": "jetstream"
                }
            ]
        }
    }
}

"$schema" value is not required, but it will add a full completion for all JSON keys.


These completions will be added:

  • route names for the first parameter of all routeForTenant methods
  • route names for the first parameter of the customRouteFunction function
  • route names for all parameters of the anotherRoute function
  • route actions (the same as for action() function) for the second parameter of actionForTenant method of classes with Tenant name
  • config keys for the first parameter customConfig function
  • config keys under filesystems.disks root for the first parameter of storageFunc function. Typical completion is local, public, s3.
  • translation keys for the first parameter of customTrans function
  • view names for the first parameter of customView function


View root with test namespace and "test/views" path will appear in the completions. All paths are related to the ide.json path, so test folder should be in the same directory with ide.json file.


All blade files in the directory/with/blade/component/views folder will be used as blade components with namespace: <x-namespace::foo>


Jetstream package converts all views from its resources/views/components folder to blade components by changing jetstream namespace to empty and adding jet- prefix. Laravel Idea has support for Jetstream, but all this "support" can be implemented by this simple instruction in the ide.json file.