Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retrieve PHPUnit binary path from project settings #1

Open
Gert-dev opened this issue Mar 9, 2017 · 4 comments
Open

Retrieve PHPUnit binary path from project settings #1

Gert-dev opened this issue Mar 9, 2017 · 4 comments

Comments

@Gert-dev
Copy link

Gert-dev commented Mar 9, 2017

Hello!

Nice to see that there is some development around having a central tester package with other packages plugging in the service. It ensures a consistent look and reduces duplicate efforts.

I noticed that in the settings, there is a path to the global PHPUnit binary. If it's not set, the package will try to execute phpunit from the folders in your current path without it. I wanted to request if the path to this binary could be retrieved from the current project's settings. This can be done via the project-manager package's service.

I've explained the procedure as well as the reasons for doing it here [1], but wanted to share it with you as well, in the hopes of getting more packages to save and restore settings via the active project.

Thanks!

[1] itmecho/atom-phpunit#4 (comment)

@recca0120
Copy link
Owner

Hello

I 'm not sure how to use it.
Could you send a pr for this issue ??

@Gert-dev
Copy link
Author

Gert-dev commented May 9, 2017

Thanks for your response. I'm a bit short on time as my own packages are rather large in scope, but I implemented this for php-integrator-base and will be happy to give you pointers about what to do, if you need them.

Basically, what you need to do is:

  1. Add project-manager to package.json, like here.
  2. Add the method you chose there in your package's main file and listen for the project changing, like here.
  3. Then you can just load any property you want from the project, like here.

Basically, once project-manager passes you the project, you can call project.getProps(), which is an object containing all the properties set in your projects.cson file for that project. project-manager automatically adds entries to the projects.cson file if you save projects with it, which you can open up manually and add settings to.

A project could look like this (the php key was automatically added by php-integrator-base and is not present by default):

{
    title: "Some Project"
    paths: [
      "/home/user/Projects/some-project"
    ]
    php:
      enabled: true
      php_integrator:
        enabled: true
        phpVersion: 7.1
        excludedPaths: []
        fileExtensions: [
          "php"
        ]
  }

If you need it, you can also let your package save new settings to a project by using the saveProject call from the service, like here.

For tester-phpunit, you could simply do something like project.getProps().php?.phpunit?.binary?. If it is set, use its value as PHPUnit path. If not, default to the path from the package settings.

This will be great for users that have many projects that are all different. Having decent support for project settings in more packages will hopefully make the Atom team aware that it is desired as default functionality and IDE scenario's :-).

@recca0120
Copy link
Owner

When I use php-integrator, can I get php binary path from php-integrator settings?

@Gert-dev
Copy link
Author

The PHP binary path for php-integrator is currently not in the project settings as it's the PHP binary that is used for the indexer (which could be different from the one used in the project). In php-integrator you can e.g. set PHP 7.1 to use for indexing for performance, but set your project version to 5.6 and it'll automatically treat it differently.

However, I added an extra php key as parent for php_integrator on purpose so other PHP packages can put their settings under the same php key, so if you like, you can optionally check for php.tester_phpunit.binary or php.binary or similar if you like.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants