Exception clickthrough using DDEV and Vscode on Drupal 10 with Ignition - drupal

I'm using the Ignition module on Drupal 10.
When I encounter an exception, the link to open the file is invalid; it points to the file inside of the DDEV container, something VSCode can't see.
How can I get serve my website via DDEV, and get the click-through function working with DDEV?
Test
Install Ignition module on Drupal 10.
Create a new module, with a route that has a missing controller.
bad_module.settings:
path: '/bad_module'
defaults:
_controller: 'Drupal\bad_module\Controller\MissingController'
_title: 'Bad routing'
requirements:
_permission: 'administer modules'
Access '/bad_module' will throw an InvalidArgumentException exception due to missing controller.
Click "ClassResolver:24" should open my IDE at the file.
Drupal: 10.0
Ignition: 1.0#alpha2
OS: WSL2 Ubuntu on Win10
VSCode: 1.74.3
DDEV: 1.21.4, vHEAD-a0f42dd

Solution
There seems to be 2 things we need to fix:
Get web container to use our config file.
# Create a new one
touch ./.ddev/homeadditions/.ignition.json
# Alternatively, use an existing one as the new base
mv ~/.ignition.json ./.ddev/homeadditions
Configure .ignition.json to remap the directories.
"editor": "vscode-remote",
"remote_sites_path": "/var/www/html",
"local_sites_path": "wsl+Ubuntu/home/user13/drupal/ignition-d10-demo"
Because I'm using DDEV and VSCode via WSL, I need to following settings:
vscode-remote is VCode using one of the remote extensions
remote_sites_path is the project root inside DDEV
local_sites_path is the path of my project where
wsl is the remote style (as opposed to ssh)
Ubuntu is the WSL OS (wsl -l)
/home/user13/drupal/ignition-d10-demo is the path inside WSL (pwd)
Full .ddev/homeadditions/.ignition.json
{
"theme": "dark",
"editor": "vscode-remote",
"hide_solutions": false,
"remote_sites_path": "/var/www/html",
"local_sites_path": "wsl+Ubuntu/home/user13/drupal/ignition-d10-demo"
}

Related

Upgraded Drush 8 to 9 Site Alias Not Working

I moved from using Docksal to Acquia ADS (Lando) which automatically upgraded my Drush from 8 to 9. My local site works fine but I can't get Drush 9 to "see" my Drupal 8 site. The aliases seem to have been created and added to the drush/sites folder and running drush site:alias does show them. However running drush status shows my Drupal root as /app. My Drupal root is /app/docroot. My alias files do have this as their root (for local). I'm not sure why Drush doesn't use the alias files it knows about. I've tried:
drush #self(or #local) list and I get some commands and this statement at the end:
[NOTE] Drupal root not found. Pass --root or a #siteAlias in order to see Drupal-specific commands.
Doing drush #local(or #self) cr returns:
In BootstrapHook.php line 32: Bootstrap failed. Run your command
with -vvv for more information.
With -vvv:
Exception trace: at
/app/vendor/drush/drush/src/Boot/BootstrapHook.php:32
Drush\Boot\BootstrapHook->initialize() at
/app/vendor/consolidation/annotated-command/src/Hooks/Dispatchers/InitializeHookDispatcher.php:34
Consolidation\AnnotatedCommand\Hooks\Dispatchers\InitializeHookDispatcher->callInitializeHook()
at
/app/vendor/consolidation/annotated-command/src/Hooks/Dispatchers/InitializeHookDispatcher.php:27
Consolidation\AnnotatedCommand\Hooks\Dispatchers\InitializeHookDispatcher->initialize()
at
/app/vendor/consolidation/annotated-command/src/CommandProcessor.php:145
Consolidation\AnnotatedCommand\CommandProcessor->initializeHook() at
/app/vendor/consolidation/annotated-command/src/AnnotatedCommand.php:289
Consolidation\AnnotatedCommand\AnnotatedCommand->initialize() at
/app/vendor/symfony/console/Command/Command.php:221
Symfony\Component\Console\Command\Command->run() at
/app/vendor/symfony/console/Application.php:1005
Symfony\Component\Console\Application->doRunCommand() at
/app/vendor/symfony/console/Application.php:255
Symfony\Component\Console\Application->doRun() at
/app/vendor/symfony/console/Application.php:148
Symfony\Component\Console\Application->run() at
/app/vendor/drush/drush/src/Runtime/Runtime.php:118
Drush\Runtime\Runtime->doRun() at
/app/vendor/drush/drush/src/Runtime/Runtime.php:49
Drush\Runtime\Runtime->run() at /app/vendor/drush/drush/drush.php:72
require() at /app/vendor/drush/drush/drush:4
drush status:
PHP binary : /usr/local/bin/php
PHP config :
PHP OS : Linux
Drush script : /app/vendor/drush/drush/drush
Drush version : 10.2.2 <-- Had 9.0.0 but currently trying 10, same issue
Drush temp : /tmp
Drush configs : /root/.drush/drush.yml
/app/vendor/drush/drush/drush.yml
/app/drush/drush.yml
Drupal root : /app
self.site.yml:
local:
root: /app/docroot
uri: example.lndo.site
Can someone please point me in the right direction?
Figured it out. No matter how many ways you try to tell Drush where to look to find your Drupal root, none of it will matter until you edit your composer.json file. Turns out the key to making Drush 9+ work is changing the name in composer.
My composer.json file name went from:
"name": "drupal/drupal",
to:
"name": "drupal-composer/drupal-project",
I don't think this feature was documented anywhere so I'm posting it here in response to my own question in case this helps anyone else.
I realize that this is an older question, however with Drupal 8 recently reaching end of life, and the high probability of many people (like myself) scrambling to upgrade now that clients have realized the risks of using EOL software, I want to take a moment to explain why #r00t's answer works.
r00t is correct that changing the "name" value in composer.json fixed the issue, however, the value that is set is not limited to drupal-composer/drupal-project. This seems to stem from the package webflo/drupal-finder and the way it works.
webflow/drupal-finder is a requirement of drush/drush, so it's going to be included even if you haven't added it manually. It's also a requirement of a couple of others that you may or may not have installed, like palantirnet/drupal-rector (which as a side note, is really helpful for this upgrade).
Within the code for drupal-finder is a method that looks for the install path of Drupal core based on a few items within your composer.json file.
Here is the code from DrupalFinder::isValidRoot()
foreach ($json['extra']['installer-paths'] as $install_path => $items) {
if (in_array('type:drupal-core', $items) ||
in_array('drupal/core', $items) ||
in_array('drupal/drupal', $items)) {
$this->composerRoot = $path;
// #todo: Remove this magic and detect the major version instead.
if (($install_path == 'core') || ((isset($json['name'])) && ($json['name'] == 'drupal/drupal'))) {
$install_path = '';
} elseif (substr($install_path, -5) == '/core') {
$install_path = substr($install_path, 0, -5);
}
....
Which is telling drupal-finder that if the "name" value is drupal/drupal then the install path of the site is at the base of the project, however if it is not drupal/drupal then use a value from extra.installer-paths to find the site install.
I'm still not aware if this is documented anywhere on either webflo/drupal-finder or in drush/drush, but understanding why it was an issue helped me out tremendously.
TL;DR:
If your site's docroot lives next to your vendor folder, change the name in composer.json to anything that isn't drupal/drupal. If your vendor folder lives inside your docroot, drupal/drupal will work for you.

Open files in PHPStorm with Vagrant+Symfony application

I know you can open files from Symfony profiler or exception file links using this in project/app/config.yml :
framework:
ide: "phpstorm://open?file=%%f&line=%%l"
More info: http://developer.happyr.com/open-files-in-phpstorm-from-you-symfony-application
However as I'm using vagrant, the file path of the server doesn't match my host.
I have created a PHP web application server in PHPStorm with the propper path mappings, but still doesn't work.
Any ideas?
Thanks
When running your app in a container or in a virtual machine, you can tell Symfony to map files from the guest to the host by changing their prefix. This map should be specified at the end of the URL template, using & and > as guest-to-host separators:
// /path/to/guest/.../file will be opened
// as /path/to/host/.../file on the host
// as /path/to/host/.../file on the host
'phpstorm://%f:%l&/path/to/guest/>/path/to/host/&/foo/>/bar/&...'
Symfony FrameworkBundle Configuration - IDE
The answer given by Jeffry no longer works unfortunately :(. When In configure that with my paths the profiler throws:
ParameterNotFoundException
You have requested a non-existent parameter "f:".
I have configured the path according to this line in the SF docs: This map should be specified at the end of the URL template, which results in this:
phpstorm://open?url=file://%%f&line=%%l&/path/to/guest/>/path/to/host/
However, it does open PHPStorm, but phpstorm does not open the file, so i'm a bit stuck here now.
This solves the issue with the file not opening in PhpStorm from a Vagrant:
phpstorm://open?file=%%f&line=%%l&/path/to/guest/>/path/to/host/
Source: https://youtrack.jetbrains.com/issue/IDEA-65879

How to disable default nginx site when using Chef and Vagrant?

I am using Berkshelf, Chef and Vagrant and I am trying to configure a custom site running on nginx. I am using the opscode nginx recipe and then writing my own recipe for the custom site. When I run vagrant up I get the an error about not disabling the default nginx site. I've found several different suggestions but nothing seems to be working.
The error:
STDOUT:
STDERR: nginx: [emerg] a duplicate default server for 0.0.0.0:80 in /etc/nginx/sites- enabled/kyleboon.me:2
nginx: configuration file /etc/nginx/nginx.conf test failed
My Berksfile:
site :opscode
metadata
cookbook 'nginx'
The 'roles/web.json' role I defined:
{
"name": "web",
"chef_type": "role",
"json_class": "Chef::Role",
"description": "The base role for systems that serve HTTP traffic",
"default_attributes": {
"nginx": {
"default_site_enabled": false
},
"app": {
"name": "kyleboon.me",
"web_dir": "/var/data/www/kyleboon.me"
},
"user":{
"name": "vagrant"
}
},
"run_list": [
"recipe[nginx]",
"recipe[kyleboon.me]"
]
}
Here is the recipes/default/default.rb for the nginx site I am adding:
nginx_site 'default' do
action :disable
end
%w(public logs).each do |dir|
directory "#{node.app.web_dir}/#{dir}" do
owner node.user.name
mode "0755"
recursive true
end
end
template "#{node.nginx.dir}/sites-available/kyleboon.me" do
source "site.erb"
mode 0777
owner node.nginx.user
group node.nginx.user
end
nginx_site "kyleboon.me"
cookbook_file "#{node.app.web_dir}/public/index.html" do
source "index.html"
mode 0755
owner node.user.name
end
(P.S. I know the file permissions need to be changed, I've just been fiddling with lots of things, I'll update those once I get everything else working)
And here is attributes/default.rb:
override['nginx']['enable_default_site'] = false
You can see I have tried to disable the default site in the web.json, the attributes and the recipe itself but none of them stick.
I don't have a node or solo node defined and I'm not sure if that's an issue. My main problem with vagrant so far has been the endless possibilities for how to do things. No two examples are done in the same way and I'm not sure what is considered the 'best' or 'right' way to go.
You can disable any nginx site by name using the nginx_site and its name. The problem you are having is because the nginx_site definition is actually looking for the enable parameter to be set to true or false not the action parameter set to :disabled.
To disable the default site add to your recipe:
nginx_site 'default' do
enable false
end
This is working for me as of version 1.7.1 of the nginx opscode cookbook. I dont know if this will work with the version provided by community as it appears to be several months old.
To get the latest version add to your Berksfile:
cookbook 'nginx', git: 'https://github.com/opscode-cookbooks/nginx'
Hope that helps :)
I'm getting the same error, but I don't have the default site enabled. Instead, it's coming from /etc/nginx/conf.d/default.conf! I had to resort to
file "/etc/nginx/conf.d/default.conf" do
action :delete
end
This is coming from the RHEL package that the nginx cookbook is installing on my box.

Drush install on local server error (Command pm-enable needs a higher bootstrap level)

I am getting an error message in Drush on a local mamp install
PDO::__construct(): [2002] Connection refused (trying to connect via tcp://127.0.0.1:3306) [warning]
environment.inc:517
Command pm-enable needs a higher bootstrap level to run - you will need to invoke drush from a more [error]
functional Drupal environment to run this command.
The drush command 'en devel' could not be executed. [error]
Drush was not able to start (bootstrap) the Drupal database. [error]
Hint: This may occur when Drush is trying to:
* bootstrap a site that has not been installed or does not have a configured database. In this case
you can select another site with a working database setup by specifying the URI to use with the --uri
parameter on the command line. See `drush topic docs-aliases` for details.
* connect the database through a socket. The socket file may be wrong or the php-cli may have no
access to it in a jailed shell. See http://drupal.org/node/1428638 for details.
Drush was attempting to connect to:
Drupal version : 7.21
Site URI : http://default
Database driver : mysql
Database hostname : 127.0.0.1
Database username : root
Database name : geoslate
Default theme : garland
Administration theme: garland
PHP configuration : /private/etc/php.ini
Drush version : 5.8
Drush configuration:
Drupal root : /Applications/MAMP/htdocs/geoslate
Site path : sites/default
Modules path : sites/all/modules
Themes path : sites/all/themes
File directory path: sites/default/files
%paths : Array
my drupal settings needed a port specifying which is on the MAMP home page and for me is 8889

Flex, zend production error

I've got my flex, php & zend project working fine on localhost but when I try to move it to production I get the following error:
Class "testService" does not exist: Plugin by name 'testService' was not found in the registry; used
paths:
: /home/myNewFolder/services/
#0 /home/ZendFramework/library/Zend/Amf/Server.php(550): Zend_Amf_Server->_dispatch('paged', Array,
'testService')
#1 /home/ZendFramework/library/Zend/Amf/Server.php(626): Zend_Amf_Server-
>_handle(Object(Zend_Amf_Request_Http))
#2 /home/myNewFolder/gateway.php(69): Zend_Amf_Server->handle()
#3 {main}
I've got my amf_config file as follows:
[zend]
webroot =/home/myNewFolder
zend_path =/home/ZendFramework/library
[zendamf]
amf.production = false
amf.directories[]=services
my .swf & services folder are located in "myNewFolder", which is located under the root of my directory.
I am using Zend version 1.9.4, Flex SDK 4.1. My localhost is windows & production host is Linux
two potential problems, the home on the server is not the path you think. Print home to screen to see what is there. Second, always, always use small letters. Too many problems arise when you write myApp, MyApp or Myapp. just write myapp, and do not worry again
Edit: wait a second, your services path is wrong. I assume it is under New Folder. Your amf directories should change to amf.directories[]=./services
Remember that Unix is case sensitive, and Windows doesn't so check the case, your file should be named testService.php, or TestService.php.

Resources