How do I setup Drupal Console on Windows 7? - drupal

How do I install/setup Drupal Console on Windows 7? In the video by the author, the environment used is Linux.
I tried to install it on Windows 7, but I wasn't able to use it to generate a module code.

You can download the drupal console either using Git Bash
$curl https://drupalconsole.com/installer -L -o drupal
Or using windows command prompt
c:\>php -r "readfile('https://drupalconsole.com/installer');" > drupal
After downloading this file, place it beside php.exe file within your php folder (not project folder), restart your terminal/cmd-prompt and type
$drupal
to get started.
Besides downloading Drupal Console .phar file, you can also install Drupal Console using composer on windows.
First Download and install composer in your system.
Then on your windows command prompt or git terminal
$composer global require drupal/console:#stable

Create a file called drupal.bat
#php "%~dp0drupal.phar" %*

Here's the full list of steps I took:
php -r "readfile('https://drupalconsole.com/installer');" > drupal.phar
added installation location to the global PATH
created a drupal.bat file in the same directory as drupal.phar. drupal.bat contains: #php "%~dp0drupal.phar" %*
Now you can call >drupal from any location. I would upvote #Nate's answer, but this is a new account.

Open Git bash (or any terminal with curl capability)
Run curl https://drupalconsole.com/installer -L -o drupal.phar
Create file drupal.bat with content #php "%~dp0drupal.phar" %*
Copy both files (drupal.phar and drupal.bat) into C:\WINDOWS
Open new Command prompt window then try typing drupal list.
This steps assume:
Your PHP is on Path environment variables and you can run php --version.
You have Git for Windows installed.

you can install drupal console using composer
open the command line on windows then go to :
cd /path/to/drupal8.dev
now you can install drupal console :
composer require drupal/console:~1.0 --prefer-dist --optimize-autoloader
after that you installed drupal console you can use it from drupal root directory where composer.json exist as follow:
vendor/bin/drupal <the_command>
you should replace <the_command> with one of the drupal console commands. you can see complete list of the commands here: drupal console commands

Find a php.exe
Add this path to the environnement variable path
from terminal run
php -r "readfile('https://drupalconsole.com/installer');" > drupal.phar
i then use php-storm IDE :
file/settings/command line
add tool based on symfony console
fill php path and drupal.phar path
console is now set
tools/run command
drupal list

if you have php and composer all setup
make sure you're in your drupal root folder..open powershell (anyother cli) and do '
composer require drupal/console
'after this add.
'C:\<path to your drupalwebsite root folder>\vendor\bin'
to your paths Environment variables
and you have composer installed: Remember to install and add composer to path variables for every local drupal installation.

Related

Laravel & Valet: Failed to open stream

I'm trying to setup a Laravel project on Valet.
I'm getting this error:
Warning: require(/Users/davina/Developer/learn-laravel-graphql/public/../vendor/autoload.php): failed to open stream: No such file or directory in /Users/davina/Developer/learn-laravel-graphql/public/index.php on line 24
Fatal error: require(): Failed opening required '/Users/davina/Developer/learn-laravel-graphql/public/../vendor/autoload.php' (include_path='.:/usr/local/Cellar/php/7.3.1/share/php/pear') in /Users/davina/Developer/learn-laravel-graphql/public/index.php on line 24
Trying to link either the project root or /public folders results in the above error instead of Laravel's default welcome screen.
How do I resolve this?
Try to navigate to the project folder root and run the command:
composer -i
sudo chmod 755 -R folder_name
Create the .env file, if is fresh application just copy the content of the .env.example file.
inside the project folder again: php artisan key:generate
After those steps all up and running for me :)
Solves the issue for me.
Looks like you have a fresh installation of laravel here...or, you just cloned the repo?
If so, the first thing you should do is to try and install the packages that Laravel uses.
Within those packages is a file called "autoload.php" which your server is looking for here.
Now, to do that, simply navigate within your terminal to the directory of your project and run: composer install.
Wait for it to finish and then, try to continue from there.

heroku cli commands not responding on windows 10

I installed heroku cli on windows 10 via exe installer.
When i try to run heroku --version command or heroku login
command, the command window does not respond. It does not give any error.
Then i uninstalled it and installed it using npm install -g heroku-cli
but getting same result.
Node version - 8.7.0
In Windows cmd prompt, do:
echo %USERPROFILE%
Go to your C:\Users\YOURNAME
Look for a file named:
_netrc
This file stores login credentials. Delete it.
Then check for an update:
heroku update
Then try to log in:
heroku login
I saw some people create an environment variable called HOME and add the path to YOURNAME so the environment knows to look for the _netrc file there.
Other trouble-shooting ideas if the above doesn't work for you can be found at Heroku CLI troubleshooting
In windows , run %LOCALAPPDATA%\heroku, completely delete this folder. and check again on cmd by typing heroku --version. Hope this helps.
I ended up uninstalling heroku from the Windows Installer and instead used the standalone tarball.
You can get the tarballs from here.
After you downloaded and extracted it, you can go to your terminal and cd into the directory where you extracted the file and do the following command:
./bin/heroku --version
Whenever you need the heroku CLI, you can cd into the directory where heroku is, then ./bin/heroku is the executable for heroku.

Drupal - drush installation on mamp server

I have a drupal project, and I am trying to install drush for mamp server. I have run:
composer global require drush/drush:dev-master
In the directory of my project, but when I am trying to run:
drush status
I get:
command not found: drush
Follow information listed in : https://www.drupal.org/node/1674222
At the very least, you definitely did not carry these two steps out correctly, which symlink the "drush" binary.
cd /usr/bin
ln -s /Users/myusername/drush/drush
Replace /Users/myusername/ with the name of the directory where you unpacked Drush.
You may need to quit and restart Terminal after completing these instructions before running any drush commands.
http://youtu.be/TCg02d4am_Q for more details
If you're still having problems, I suggest following the instructions here: https://www.drupal.org/node/1674222 and reporting back, editting your answer to reflect the new error you get, so we can actually help you figure out what step of the install you're not running successfully.

intalling PHPUnit on Windows

I have XAMPP 5.6.3 installed on Windows 32bits (PHP Version 5.6.3), and I want to install PHPUnit.
I followed the instruction in the official site of PHPUnit :
https://phpunit.de/manual/current/en/installation.html#installation.phar.windows
but when I run this line phpunit --version in the command line, I get this message :
'php' is not recognized as an internal or external command, operable program or batch file.
how can I solve this problem ?
The problem was that PHP is not included in my PATH.
So I followed this solution :
Windows button + Pause
List item
Advanced System Settings
Environment Variables
append PHP installation dir to the PATH variable.

Module installation using drush giving error

I have downloaded drush and cofigured it properly .Now I am trying to download a module "themekey" and install it to my drupal .Its downloading properly using
drush dl themekey
but when I try to install it using
drush en -y themekey
I get this error
drush en -y themekey
Command pm-enable needs a higher bootstrap level to run - you will [error]
need to invoke drush from a more functional Drupal environment to run
this command.
The drush command 'en themekey' could not be executed. [error]
A Drupal installation directory could not be found
Please help me in this , I am new in drpal drush and did not find way to solve this
Here is my drupal folder
/opt/lampp/htdocs/projects/drupal_test/
You need a working drupal installation, meaning php can be executed the mysql server can be reached. Then you have to change into the root directory of your installation - in your case:
cd /opt/lampp/htdocs/projects/drupal_test/
and execute the command:
drush en modulename -y
For debugging use
drush rq
If you tried changing localhost to 127.0.0.1 in settings and it still doesn't work, please have a look at the solution I found here:
Drush: “Command pm-enable needs a higher bootstrap level to run
When running drush you can run into this error message. In my case, the mysql command line tool provided with Mamp Pro was not available. You can easily test this by typing the command ‘mysql’ in terminal. Your output might be -bash: mysql: command not found.
To solve this, do the following in terminal:
sudo vim ~/.bash_profile
Press i
Move to the last line and append
export PATH=/Applications/MAMP/Library/bin/:$PATH
Hit escape
Type in :wq (including the colon) to write the file and quit vim.
Reload your profile by running source ~/.bash_profile.
The mysql command AND drush should now work!

Resources