Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,28 @@ Changelog

## develop

Features:

- [goto-definition] Goto definition extracted from core into separate
packages including [extension
point](https://github.com/phpactor/reference-finder-extension).
- [goto-definition] Support for "plain text" goto class definition, works
for docblocks, and non-PHP files.
- [completion] Do not suggest static members on non-static calls and
vice-versa.

- [completion] Do not suggest non-static method on static calls.
- [completion] Suggest ::class constant, fixes #673
- [completion] Docblock type injection allow name to be omitted #618
- [application] Log errors in command error handler (for logging async
completion errors using the complete command)

Improvements:


Bug fixes:

- [completion] Fix type resolution immediately following docblock #678
- [completion] Include `$` on static properties #677
- [extension-manager] Do not install dev dependencies for extensions #674

## 2018-12-02 0.11.0

BC Break:
Expand Down
44 changes: 23 additions & 21 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions doc/extensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ to create new applications.
Currently Phpactor ships with a dozen "hard coded" extensions which cannot be
removed.

For some extension examples see the [integrations](/integrations.html) page.

Usage
-----

Expand Down Expand Up @@ -47,4 +49,5 @@ Package operations: 1 install, 0 updates, 0 removals
Writing lock file
Generating autoload files
```

Removing is done via. `extension:remove`.
122 changes: 16 additions & 106 deletions doc/integrations.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,117 +4,27 @@ currentMenu: integrations
Integrations
============

Any PHP application or framework which uses composer in a _normal_ way will
play nicely with Phpactor, for the others there is this page.
Phpactor will work by default with any project which uses composer in a
standard way. Some platforms (e.g. Drupal 8) will need more attention,
additionally there are various extensions which can be installed to integrate
with specific tooling.

Drupal 8
--------
Tools
-----

### Bootstrapping
### Behat

Drupal automatically adds its modules to the autoloader during the kernel
boot process. It is therefore necessary to either 1) boot the kernel to have a fully
useful autoloader *or* 2) to use a different mechanism to add the modules to the Composer autoloader.
The [behat extension](https://github.com/phpactor/behat-extension) provides
completion and goto definition support.

Depending on your setup option 1 or 2 will be preferable.
### PHPUnit

In both cases deregister the autoloader in `.phpactor.yml`:
The [PHPUnit extension](https://github.com/phpactor/phpunit-extension)
provides test class generation and type inference.

```yaml
# Bootstrapping Drupal creates lots of implicit global
# dependencies, so we will just keep the Drupal autoloader
# registered and hope for the best.
composer.autoload_deregister: false
```
Platforms
---------

#### Option 1: Bootstrap Drupal on the fly to generate the autoloader
### Drupal 8

Create the following bootstrap file `autoload_phpactor.php`, in (for example)
`web/`:

```php
// web/phpactor_autoload.php
<?php

use Drupal\Console\Core\Utils\DrupalFinder;
use Drupal\Console\Bootstrap\DrupalKernel;
use Symfony\Component\HttpFoundation\Request;

$autoload = require_once __DIR__ . '/autoload.php';

$root = getcwd();

$drupalFinder = new DrupalFinder();
if (!$drupalFinder->locateRoot($root)) {
die('DrupalConsole must be executed within a Drupal Site.');
}

chdir($drupalFinder->getDrupalRoot());

$drupalKernel = DrupalKernel::createFromRequest(
Request::createFromGlobals(),
$autoload,
'dev',
true,
$drupalFinder->getDrupalRoot()
);
$drupalKernel->boot();
chdir($root);

return $autoload;
```

Then edit `.phpactor.yml` to use that:

```yaml
# Use the special autoloader above
autoload: web/phpactor_autoload.php
```

The downside to this option is that it requires access to the DB from your current environment which may be tricky if you are running Drupal inside a VM.

#### Option 2: Add the modules into the Composer autoloader

This option requires merging in any modules (Drupal, contrib, custom) into the Composer autoloader via a discovery mechanism offered by the [Drupal Autoloader](https://github.com/fenetikm/autoload-drupal) composer plugin.

Full details are available in the README for this plugin, however, the short version is that you will need to put the following into your `composer.json` file:

```json
{
"require": {
"fenetikm/autoload-drupal": "0.1"
},
"extra": {
"autoload-drupal": {
"modules": [
"app/modules/contrib/",
"app/modules/custom/",
"app/core/modules/"
]
}
}
}
```

and then rebuild your Composer autoloader e.g.

```sh
composer autoload-dump
```

The upside to this option is that it won't require the relatively slow Drupal bootstrap (which will hit the DB) but the downside is that you will have to regenerate the autoloader every time you add / remove a module.

#### Coding Standards

Change your local `.phpactor.yml` to use 2 spaces for indentation:

```
# Drupal CS is 2 spaces
code_transform.indentation: " "
```

<div class="alert alert-info">
Code will still be generated using the PSR-2 standard. It would be necessary
to override twig templates in `.phpactor/templates` to rectify this (or just
use a CS fixer).
</div>
See the [Drupal 8](/integrations/drupal8.html) guide.
Loading