Code Monkey home page Code Monkey logo

vscode-laravel-artisan's Introduction

Laravel Artisan

Run Laravel Artisan commands from within Visual Studio Code.

Features

  • Supports multiple instances of artisan in the same workspace hierarchy
  • Make files (Controllers, Migrations, Models, etc)
  • Run Custom Commands
  • Manage the database
  • Clear Caches
  • Generate Keys
  • View all routes
  • Start/stop a local php server for test purposes
  • Docker support

Get a list of routes

Route List

Make a controller

Make Controller

Requirements

Note: The php setting is optional if the setting artisan.php.location is set in your settings.json file and points to a valid php executable. If this setting is set, the extension will prefer the setting over the one within the path.

  • A useable version of php that can be ran on the command line such as php-cli (This should be in your path)
    • The following command should yield a php version:
    • php -v
      • If no php version is returned you don't have php setup correctly.
      • If you get a version back you are good to go!
  • A Laravel install that has artisan in the workspace root
    • cd into your root directory and run the following command:
    • php artisan -v
      • If an error is returned you don't have laravel setup correctly.
      • If you get a Laravel version and a list of commands you are good to go!

Usage

Command Pallet

Once you have installed the extension, it will become active once you open a workspace that has at least one artisan file within the workspace. You can then open the command pallet, and start running the commands. Just type Artisan: to get a list of commands. If you have more than one artisan file within the workspace, then this will ask which artisan file you want to use to execute the selected command.

Many commands have optional input questions, leave them blank to use the defaults, or enter your own value.

All commands are accessible through Artisan: Run Command, here you can access your custom commands as well as built in commands.

Context Menu

You can also right click on some files and folders to run commands, the context menu will only show commands that are relevant to the file or folder you have right clicked on. The context menu will show on child folders and files as well as the main folder.

  • app – Run app related commands.
    • Make – To make app files.
    • Serve – To start/stop a local php server.
  • database – Run database related commands.
    • Make – To make database files.
    • Migrate – To run migrations.
  • resources – Run resource related commands.
  • routes – Run route related commands.
  • Misc – Run misc commands (displayed on all files & folders).

Docker

If you are running Laravel with Docker you can set config vars like this, considering your docker-compose.yml is placed on project's root.

{
  "artisan.docker.enabled": true,
  "artisan.docker.command": "docker-compose exec <app>"
}

Where <app> is your container name. Note this is a base command that will prepend to artisan commands.

Example:

docker-compose exec app php artisan make:model Post

Before running any commands, make sure the containers are running (docker-compose up).

WSL

If php is installed with WSL (Windows Subsystems for Linux), add the path to the executable in settings.json like below

Newer versions of WSL

When using the newer versions of WSL, you can set the artisan.wsl setting to true and the artisan.php.location setting to /usr/bin/php to use the default php installation.

{
  // Opens wsl and runs the command in the wsl shell
  "artisan.wsl.enabled": true,
  // Optional if you have php installed in a different location that the one in the path:
  "artisan.php.location": "/path/to/php"
}

Older versions of WSL

  • Replace <username> with the correct user name
  • Replace CanonicalGroupLimited.Ubuntu18.04onWindows_79rhkp1fndgsc with the proper package name
  • Replace usr\\bin\\php if php is installed in different location
{
  "artisan.php.location": "C:\\Users\\<username>\\AppData\\Local\\Packages\\CanonicalGroupLimited.Ubuntu18.04onWindows_79rhkp1fndgsc\\LocalState\\rootfs\\usr\\bin\\php"
}

vscode-laravel-artisan's People

Contributors

aaronlil avatar adithyaharun avatar ahmedmsvb avatar ahuahuachi avatar carestad avatar cesaramirez avatar dependabot[bot] avatar ehsansabet avatar heinzin avatar nicoeg avatar nightbringer01 avatar paulhennell avatar qcmarcel avatar robsontenorio avatar sepehrr avatar simoebenhida avatar thecolorred avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

vscode-laravel-artisan's Issues

WSL php support?

I'm using PHP inside WSL, also VSCode terminal is setup using "terminal.integrated.shell.windows": "C:\\Windows\\System32\\wsl.exe",

So none of artisan commands not launching using this extension, due to missing php or paths (VSCode installed in WIndows, PHP installed in WSL)

In integrated terminal artisan commands works well.

Console output:

[CMD] php artisan route:list
[ERROR] 
[CMD] php artisan make:command ads --command=asd
[ERROR] 
[CMD] php artisan route:list
[ERROR] 
[CMD] php artisan cache:clear  
[ERROR] 
[CMD] php artisan make:controller TestController --resource
[ERROR] 

Lacks make:rule command

This command is very useful for creating customized validation rules starting Laravel 5.5, which fact I figured out when watching "Let's Build A Forum with Laravel and TDD" on Laracasts.
However this useful command is still missing in this wonderful extension (yeah I almost threw terminal after this extension was installed haha). It'd be sweet if the author adds the command in next version ;)

New Options on Make Controller

Helo There,

I recently begins to work with API only project on Laravel, using the plugin, i can't create the model (Artisan: Make Model) with the option "resource", because in the API, has two less methods in the controller.

I can't use the create controller (Artisan: Create Controller) either, because he only asks if the model is a resource, if i say YES, he create the controller with the two methods i don't want.

I think you can add some option on the Create Controller to ask if the controller is a API RESOURCE, like the actual.

captura de tela 2018-10-12 as 00 06 01

If i ask NO to the above questions, show the question "Should i make this a API RESOURCE controller?"

In the command generated the change is only in the place of "--resource" , is "--api".

Plus you can add a final question to add a model to the controller, a question like the name, where user can insert some name on it. The changes on the command is add at the end "--model MyModel".

By the way, congrats for this awesome plugin, helps a lot in day by day.

Regards

i am unable to run the commands in this version

  • Extension Name: laravel-artisan
  • Extension Version: 0.0.20
  • OS Version: Windows_NT x64 10.0.17134
  • VSCode version: 1.24.0

We have written the needed data into your clipboard. Please paste:

Stop Laravel Server

after runing the command there server is started, but there is no further feedback and i cant find a way to stop it, not even closing vscode

Run Custom Command

Please add support to run custom Artisan commands.

For me I use:

php artisan renew:app

Thanks.

Error running inside docker

When I try to run my docker command with this extension I got the error: the input device is not a TTY

[ERR] Command failed: cd /home/victor/projects/api/ && docker-compose exec php php artisan route:list
the input device is not a TTY

But if I just copy the command of this output and run into my terminal, works properly: cd /home/victor/projects/api/ && docker-compose exec php php artisan route:list

Does anyone have any ideia?

Laravel 4.2 support

Since the artisan commands differ when using an older Laravel version (in this case 4.2), the extension's commands fail when executed (for instance, https://laravel.com/docs/4.2/migrations).

Maybe Laravel 4.2 support should be added since legacy systems still depend on older versions of Laravel.

Homestead development

Hello!

I'd like to ask if there is any way to use this extension with Homestead properly? If I use the Config Cache or Config Refresh artisan command, my application always shows an UnexpectedValueException Protocol Error exception whenever I try to load a page. I assumed that happens because the command will need to be executed inside the VM. Well. of course, I could execute php artisan config:cache manually via SSH, but I'd rather use this extension.
So there is any way to call into play this ext, or I have to manually modify the source code? 😄

Thanks for everyone for the answer in advance!

Run Artisan in another disk

I'm facing a little problem that I believe is a bug.

The version showed in my VScode is 0.0.17.

I use several different languages, for this, I organize my projects in separate units of windows ("C:").

If you use the extension in a workspace located on the drive "C:" everything works normally, but in other units ex: "G:", the command does not execute.

I opened the console vscode itself trying to perform "Artisan Route List" and received the following return:

[Extension Host] Error: Command failed: cd "g:\Desenv\Php\MyProj" && php artisan route:list
 (See output console for more details)
Code/resources/app/out/vs/workbench/workbench.main.js:260
/C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:2217 The route list could not be generated

Apparently in Windows it is no use just to give a "CD" in the directory when the drive differs from "C:".

Running the same command generated in the terminal the error presented is that "artisan" was not found.

The following ways I can run through the terminal normally:

cd "g:\Develop\Php\MyProj" && G: && php artisan route: list

or

php "g:\Develop\Php\MyProj\artisan" route: list

PS. sorry for bad english

Command Failed: cd /d ""

The command line is failing to run due to a empty string for artisan. To fix this i tried to set the directory in the artisan.location config, this evaluates to removing any directory specifiers.

[CMD] "php" artisan make:command UserRoleManager --command=app:roles/user/add
[ERR] Command failed: cd /d "" && "php" artisan make:command UserRoleManager --command=app:add/permission
The filename, directory name, or volume label syntax is incorrect.

-- After setting artisan.location to D:\\Programming\\PHP\\Laravel\\ChaoticPanel

[CMD] "php" artisan route:list
[ERR] Command failed: cd /d "\Programming\PHP\Laravel\ChaoticPanel" && "php" artisan route:list
The system cannot find the path specified.

It seems that either the Drive specifier is being trimmed off to favour the linux file structure.

This is the stack trace incase this can help with the issue.

workbench.main.js:238 [Extension Host] 
Error: Command failed: cd /d "\Programming\PHP\Laravel\ChaoticPanel" && "php" artisan route:list
The system cannot find the path specified.
 (See output console for more details)



workbench.main.js:2365
The route list could not be generated (See output console)

onDidNotificationChange	@	workbench.main.js:2365
_register.model.onDidNotificationChange.e	@	workbench.main.js:2364
fire	@	workbench.main.js:77
notify	@	workbench.main.js:2420
notify	@	workbench.main.js:3616
r	@	workbench.main.js:3213
_showMessage	@	workbench.main.js:3212
$showMessage	@	workbench.main.js:3212
_doInvokeHandler	@	workbench.main.js:3252
_invokeHandler	@	workbench.main.js:3252
_receiveRequest	@	workbench.main.js:3251
_receiveOneMessage	@	workbench.main.js:3249
_protocol.onMessage.e	@	workbench.main.js:3248
fire	@	workbench.main.js:77
a	@	workbench.main.js:321
e	@	workbench.main.js:321
fire	@	workbench.main.js:77
_receiveMessage	@	workbench.main.js:330
S._socketDisposables.push._socketReader.onMessage.e	@	workbench.main.js:327
fire	@	workbench.main.js:77
acceptChunk	@	workbench.main.js:323
_register._socket.onData.e	@	workbench.main.js:323
t	@	workbench.main.js:332
emit	@	events.js:182
addChunk	@	_stream_readable.js:279
readableAddChunk	@	_stream_readable.js:264
Readable.push	@	_stream_readable.js:219
onread	@	net.js:636```

Test Stub

When I generate a test it extends an unexpected TestCase. It pulls in PHPUnit\Framework\TestCase when it the artisan command uses Tests\TestCase by default. Any way to update that in the configs?

Command to generate tests

This useful extension lacks the option to generate tests, so you have to switch to the terminal for that. It'd be nice to have a command for make:test.

Have to hit "Enter" twice when starting the server

When selecting start server, VSCode asks for the host and port number (recommending null for defaults).
Since we always use the default hostname and port#, it would be better to have a command "Start Server (with defaults)".

I made the needed code changes for this issue, will push the pull request soon.

stdout maxBuffer length exceeded

[CMD] "php" artisan route:list
[ERR] stdout maxBuffer length exceeded

I am not sure how to reproduce this or this is specific to this extension but is there a fix for this?
I can successfully route:list on command line but not on this extension which is very helpful.

Cannot run in Docker

I am unable to run the commands against Docker, because the commands automatically cd into the current artisanRoot directory before running the artisan.docker.command.

Code Output:

[CMD] php artisan route:list
[ERR] Command failed: cd /home/user/Code/laravel/laravel/ && docker-compose --user laradock exec workspace && cd /var/www/laravel/laravel php artisan route:list

Wondering if the docker logic could branch a bit more, so that:

  1. "artisan.docker.root-path": "cd /path/to/docker-compose/repository" could be set to know where on the local machine the artisan.docker.command should be run from
  2. "artisan.docker.path-map": { "/var/www": "/home/user/Code" } can be set to inform the command what directory in the container to run the command against.
let localArtisanRoot = artisanRoot
let dockerPathMap = config.get('docker.path-map', null)
let dockerRoot = config.get('docker.root-path', null)

if (dockerEnabled) {
    // if user did not supply a custom dockerRoot, assume we should use the local path to the current artisan
    if(!dockerRoot) {
        dockerRoot = localArtisanRoot
    }
    // if user supplied a path map, replace in the path for docker
    if(dockerPathMap) {
        Object.entries(dockerPathMap).forEach(([replace, find]) => artisanRoot.replace(find, replace ))
    }
    command = `php artisan ${command}`
    cmd = `cd ${dockerRoot} && ${dockerCommand} "cd ${artisanRoot} ${command}"`
}

In this example, cmd will evaluate to:

cd /path/to/docker-compose/repository && docker-compose exec workspace bash -c "cd /var/www/project && php artisan route:list"

Extension issue

  • Issue Type: Bug
  • Extension Name: laravel-artisan
  • Extension Version: 0.0.27
  • OS Version: Windows_NT ia32 10.0.17763
  • VSCode version: 1.41.1

⚠️ We have written the needed data into your clipboard. Please paste! ⚠️

Extension issue

  • Issue Type: Bug
  • Extension Name: laravel-artisan
  • Extension Version: 0.0.27
  • OS Version: Windows_NT x64 10.0.18363
  • VSCode version: 1.46.1

⚠️ We have written the needed data into your clipboard. Please paste! ⚠️

artisan.migrate.fresh twice

The command artisan.migrate.fresh Is declared twice in the commands section on package.json
and vscode report it.

{ "command": "artisan.migrate.fresh", "title": "Artisan: Migrate Fresh" },

Thx

custom command option

[CMD] "php" artisan module:make-controller PermissionController Admin --plain --api
I can't use options

Space in project/artisan path

I get the following error when trying any command:

[CMD] php d:\Dropbox\Project X\backend/artisan make:controller Test --resource
[ERROR] Could not open input file: d:\Dropbox\Project

Could not get the status of the migrations

firstly ,
I can use your extension is so nice and easy ,
but later,
I can't use anything commands of artisan .

always showing error ,error,error -_-

I am running on laravel 5.5 dev and PHP 7.1.7-1+ubuntu16.10.1+deb.sury.org+1 (cli)
vscode latest version

even newly laravel stable version and test your extension
but still error ..

I tested again
if I migrate refresh and ask me your extension
what database should I use ?
I typed my database name and Should I seed the database for you? yes
but result is error . not worked db seeding..

I typed just enter and should I seed the database for you? yes
but result is okay. worked db seeding..

Not working if I input the db name .

Extension fails to run if artisan location is in sub directory of the workspace

The Extension fails to run with error "command 'artisan.route.list' not found" if artisan location is in sub directory of the workspace. There is no output channel (Laravel Artisan) in console log.

When running $ cd \d "C:\\Users\\user_name\\Projects\\workspaceRoot\\laravel_project" && php artisan -v directly in the terminal, it works fine.

Additional Information:

Workspace setting:

{
    "artisan.location": "${workspaceRoot}\\laravel_project"
}

Vscode version: 1.24.1
Plugin version: 0.0.20
PHP version: 5.6
Laravel Framework version: 5.3.31

Dusk seems to be failing

When using run command and choosing dusk, vscode says that it cannot run the command (error). Any log I can attach?

Can not run any commands

Hi i am using linux and the extension does not work at all for me.

I get the following errors

[CMD] "/usr/bin/php" artisan cache:clear  
[ERR] Command failed: cd "/home/tecbeast/Code/path/to/project/" && "/usr/bin/php" artisan cache:clear

Running /usr/bin/php -v

PHP 7.2.11 (cli) (built: Oct  9 2018 18:14:59) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies

am i missing something here?

Artisan selection dropdown re-opens by itself

Any time I try to use the Artisan command through this, the selection dropdown re-opens itself a few seconds later, and doing anything to make it go away clears the routes list when that is opened.

Steps: CMD+SHIFT+P, type/select Artisan:Route List, select which artisan to use, (route list appears), a few moments later select list drops down again/will not go away

No Errors Shown in case of Command Fail

Where to see the output of command. If the command succeed then all is good but if command fails how to see the errors in this extension.
When command Fail box show up it should reference to an error page.

Publish extensions to open-vsx

I'm a VS Codium user, a FLOSS version of VS Code, it's the same code but without the Microsoft's telemetry and branding.
I want to request if possible to add the Laravel Artisan extension on the open-vsx.org market to us doesn't need to works with the Microsoft marketplace as is unclear if it's legal to use it on VS Code forks, see here.

Additional info:

  • This is how to publish a new extension.

Artisan commands are not running in VS Code

I am running a simple code from VSCode and getting following error:

[CMD] "php" artisan make:policy EmailPolicy --model=Email
[ERR] Command failed: cd /d "c:\laragon\www\zzz" && "php" artisan make:policy EmailPolicy --model=Email
'"php"' is not recognized as an internal or external command,
operable program or batch file.

If I copy/paste and run the same command via command line - it runs without any problems.

VSCode 1.40.1, Win10 x64

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.