Is there a way to run terminal commands simultaneously
Like
php artisan serve
And
npm run dev (for laravel vite)
Run it in a comment or terminal with a shortcut
Yes. There is a creative way
You should define a variable in your command line
İf you're using linux run this command:
export part="php $PWD/artisan serve"
Note:part is variable name. Name it whatever you want (part stands for php artisan)
Note:by running this command the variable will accessible just in that CMD window. That means this way is a temporary way and if you want to access it all the time you need to add this command to your .bash or .profile file
Related
How to make a shortcut that is doubled clicked and it run the laravel project automatically.
Manual process
what we do to run a Laravel project:
First of all we open the terminal(mac) or cmd (windows), then in the terminal we type the following command in order to reach the location where the laravel project is.
cd <your project location>
After accessing the project folder, we type the following command to run the project.
Php artisan serve
I want the whole process is done by a single shortcut, is it possible?, if yes, kindly help me up.
You can follow this by making shorcut, with your commands that you want to trigger.
For more help you can click on the below link:
https://www.howtogeek.com/277403/how-to-run-command-prompt-commands-from-a-windows-shortcut/
steps:
Create a shortcut by right-clicking anywhere in File Explorer or your desktop and choosing New > Shortcut.
In the Create Shortcut window, type your command using the following syntax:
"C:\Windows\System32\cmd.exe" /k yourcommand
The first part (the part in quotes) just calls cmd.exe to open the Command Prompt. The switch /k tells Command Prompt to issue the command that follows, and then stay open so that you can view results or type followup commands. You can also use the /c switch instead /k (use only one of the switches) if you want the Command Prompt window to close after issuing the command. And of course, the yourcommand part is the actual command you want to run.
"C:\Windows\System32\cmd.exe" /k cd yourProjectFolder & php artisan serve
In windows, like said before, you can create a bat script. Open notepad, write something like the following and save as "something.bat".
#echo off
Rem Change Directory to your project
cd C:\<your project directory>
Rem Run Artisan Command
php artisan serve
Then, doble click your bat file.
There is a much easier way, you could refer to this package called Laravel Valet (https://laravel.com/docs/8.x/valet), this is a package that you could install to your project folder and all laravel projects in that folder can be run automatically by entering the [project name].test in the browser once Laravel Valet is configured and started. For example, if you have a project in the folder where valet is installed, you could enter demo.test in your browser and then the project will be loaded automatically
Go and right click on your mouse or touch pad, make a shortcut, and then add command
commmand "C:\Windows\System32\cmd.exe" /k cd rootfolder & php artisan serve
I create laravel project with PhpStorm. I'm using "Git Bash Here " as terminal.
C:\Users\kadir\www\basit-laravel>php artisan make:controller TestController
'php' is not recognized as an internal or external command,
operable program or batch file.
When I try to use the contents of terminal in PhpStorm, I get this error:
By the way I use vagrant and homestead.
You have two options.
Install your php locally (not recomended, because you will run in another problems with vagrant)
Access your vagrant instance (maybe vagrant ssh in you project folder) and run the php artisan commands
There is something like this as a git bash alternative:
https://cmder.net/
You must show the terminal called git bash or cmder in php storm
How to run command php artisan serve without change to the proect directory?
I try to run this command but nothing happen
php /home/john/Documents/project/ artisan serve --port=1111
I want to insert this command to alisases at bash aliases so i don't need to insert the port anymore.
Please help me, how to run artisan with specified directory?
Try to remove space:
php /home/john/Documents/project/artisan serve --port=1111
I want to test some Laravel applications on my basic shared host.
Currently I just upload my complete application including the vendor files, however this takes quite long.
Since I do not have ssh access to my host I'd like to know whether there's an option to run composer / artisan commands without this.
I found this link: Use Composer without ssh access to server (Second Answer) which describes how to run composer using http://phpshell.sourceforge.net/
However, I can change folders in the console etc. But I cannot run php commands - I always get internal server error.
Check if your shared hosting provider has console feature in their CP which allows to run shell commands. Maybe you'll be able to run commands from there.
As alternative, you could right your own artisan runner and call artisan commands from the code:
Artisan::call('migrate');
To run composer command from PHP code, use shell_exec:
shell_exec('composer update');
I'm trying to setup phing to work with travis-ci, but I can't get it to run a setup script to get all the dependencies installed.
My .travis.yml file is:
language: php
php:
- 5.2
script: ./.travis-phing.sh
In travis, I get the error:
/home/travis/build.sh: line 105: ./.travis-phing.sh: Permission denied
What is causing that?
Solved
The script to be set to execute. I used:
chmod a+x .travis-phing.sh
Then simply commit, and push back to github.
Run the script using bash
Another option would be to run the script using bash, this would omit the need to modify the files' permissions.
bash path/to/file.sh
Alternatively:
sh path/to/file.sh
Note that
In this case you're not executing the script itself, you're executing bash or sh which then runs the script. Therefore the script does not need to be executable.
Make sense?
I've found this solution incredibly useful myself. I'm mainly running node & npm projects on travis-ci, those builds make use of the npm test command which you can configure to be anything.
I'm order to modify file permission I need to use sudo chmod ... on my local machine. But you can't always use sudo on travis-ci.
sh file.sh allows me to run my tests both locally and on travis-ci without having to manually update permissions.