How to add External Dependencies to a PHP project? - php

While trying out the VSCode on my PHP projects, I couldn't find an option/setting/extension that would allow me to add an external library and show any autocomplete tips based on the included code.
This feature is present in PHPStorm out of the box.
Am I missing something or VSCode really doesn't support this yet?

To add an external dependency you can use the VSCode multiroot workspace feature.
The File > Add Folder to Workspace... command brings up an Open Folder
dialog to select the new folder.
https://code.visualstudio.com/docs/editor/multi-root-workspaces#_adding-folders

Related

Visual Studio Code PHP autocomplete on external librarys

I use the IDE Visual Studio Code to write scripts in PHP. To write plugins in PHP for a store system, I need to add an external library to my worktree. I have already cloned the library from github and added the folder to my workspace where I am working on the plugin.
The problem is that my IDE still gives errors that namespaces and classes can't be loaded because, for example, there is no namespace with that name. I also can't use the autocomplete feature.
Can someone explain me how to fix this problem?
Screenshots:
Undefined Type [...]
I have solved this problem now! To fix this problem I needed the vscode plugin "Intelephense".
In VSCODE: right click on the folder where the interface must be used and click on "Folder Settings". In the second row under the intelephense extension the radio button "Intelephense > Environment: Include Paths" is shown. There I had to add the path to the interface.

How to create separate project to test PHP application in IntelliJ 2016?

I have a project that is written in PHP with IntelliJ. I need to create a new IntelliJ project that contains only tests for the PHP application. I can't use classes from the application in the tests project. How can I add other project as a dependency for my project that contains the tests?
I have tried using IntelliJ module settings but I don't see the dependencies tab.
I'm not sure if it works exactly like that in IntelliJ, but in PhpStorm 2016 you can do as follows:
Open Project view (View -> Tool Windows -> Project) and locate External libraries at the bottom:
Press F4 or right click -> Configure PHP Include Paths. You should see this window:
Press the + icon at the bottom of the window and locate the directory with the classes that you want to test. IntelliJ should add them as a library, which means all autocompletion features will include the classes, but you will be warned when you try to edit these files.

How would I create a dynamic Chocolatey install file?

I am currently working on a project that would automate the installation of various environments we have within the company. I have several packages created using Chocolatey.
The problem that I am having is creating a dynamic custom installation file. The current internal website allows for users to checkmark the software they wish to install. The idea would be to then allow them to click an install button which would generate an .exe file. The .exe would run the command line scripts to install the Chocolatey packages.
An example of the command line after marking the Google Chrome and Notepad++ boxes would be:
> choco install googlechrome
> choco install notepadplusplus.install
I am wondering what would be the best way to go about creating an .exe file dynamically.
Two examples I am getting inspiration from would be:
https://ninite.com/
http://getbootstrap.com/customize/
There is a chrome extension that does something similar. You may want to explore what it is doing and change it for your needs. It's called Chocolate Factory.

How do I get my HTML5 project in Netbeans to recognize PHP?

I have created a web page in NetBeans with Html 5 and CSS, and now I want to add a PHP file in that project, but there is no option to add a php file.
I added empty file (xxxxx.file) and renamed it xxxxx.php and added the php code there, but it doesn't recognize it as php code. It sees the file as php file.
What should I do? Should I create new PHP project and copy the html and css files from my old project to the php project to get them working all together?
You can have php files in HTML5 projects. If you are not seeing the syntax highlighting for the code make sure that your php files have the opening php tag:
<?php
Without this the exitor will not highlight it correctly
if PHP's aren't being recognised you should install the PHP plugin for Netbeans. You should go to Tools > Plugins > Available Plugins and select the ones for PHP in the list. Then, restart the IDE.
It seems there is a Netbeans bug which makes you impossible to add php files to html5 projects. The answer, as given by Netbeans people, is to create a new php project and add the html5 files there.
Here you can see the bug report on netbeans forum: https://netbeans.org/bugzilla/show_bug.cgi?id=226280

How to create Eclipse project from existing git repo

I have an existing project utilizing git and have just installed eclipse along with egit. I pointed to the git repository with egit and can see all my files, my existing branches and can switch between branches.
When I open a file from the view of the git repository it does not seem to recognize that it is a php file, doesn't show me the classes within it and doesn't do code completion. If I just drag a file in from explorer it at least recognizes that file as php, but doesn't understand the project well enough to show me code completion from installed libraries. I think I need to configure eclipse to understand the projects home directory, but am a bit lost. Any help would be appreciated.
Your answer may fall within this guide to change the "nature" of your project. It's at least worth exploring. I will be attempting to do the exact thing you've described some time this week so hopefully it will work. The wiki doc also suggests that certain "natures" may conflict with each other but hopefully that won't be the case here. Link -->
http://wiki.eclipse.org/IRC_FAQ#How_do_I_manually_assign_a_project_Nature_or_BuildCommand.3F
After just trying to reproduce your steps I am having the exact same experience. I believe this may be "expected" behavior. For clarity, when I open a php file from the "PHP Explorer" view everything seems to work fine but when I open a php file from the "Git Repositories" view Eclipse treats it as a text file (no code highlighting etc.). I suggest that you work from the PHP Explorer view and leave the Git Repositories view open separately only to watch/monitor the repository not as a working view of files to edit and what not.
You need to open it as a PHP Project from existing source (GIT working folder) then share the project with Git, ie, right-click on the project, go to Team > Share project, click on Git.
See http://www.youtube.com/watch?v=-Zba8iAnLms for a demo.
Did you install the pdt plugin in eclipse? It should recognize any .php file opened. Shouldn't matter where it's located.

Categories