I cannot install PhpWord Yii - yii

I have tried to install PhpWord to yii. I have downloaded zip file and extracted it into extentions folder:
extenstions
--PHPWord
--PHPWord.php
However, I cannot make it to run. I got following error:
include(PHPWord.php): failed to open stream: No such file or directory
How can i solve it?

After extracting the file in extension folder, you have to import that file in controller.
Yii::import('ext.phpword.PHPWord');

First of all, you didn't say if it's Yii 1 or 2. They have different autoloading methods.
Second, you have extracted it into extension folder, and I assume your file where you want to include it is in a completely different folder.
You should do it like this
include('/full/path/to/PHPWord.php');
You need either absolute or a relative path to the file (I suggest using abosulte path (the one I used as an example).
Relative path means the path to the file you want to include compared to where your file, in which you are including it, is.

Related

How to Create .cmake File

I was working on a project which requires me to add a user.cmake file in the root directory. Can anyone help me out hot to create the .cmake file...
Link to Project Directory
According to the link you provided user.cmake just needs to point where so-called eego sdk is located in your file system:
set(EEGO_SDK_ZIP /path/to/download/eego-sdk-1.3.19.40453.zip)
There is nothing fancy actually here, just make a plain text file, put this one line (don't forget to replace the EEGO_SDK_ZIP variable content) and save it with the name user.cmake

Relative path inside a module

I have this module which needs a specific file to work. You can pass the path of the file you want to use or not. If you don't, then a default file is taken. That default file is located at the resources folder, so I typed the path as: "resources/data/type-graph.txt". The problem is that does not work because it takes my CWD as root directory.
Do you know how to make the path relative to the module dir?
Any suggestion is appreciated :).
You should take a look at the Modules documentation page.
There this example is given to access a file placed in the resources folder:
my $template-text = %?RESOURCES<templates/default-template.mustache>.slurp;
You also need to list the file in META6.json so the file will be accessible once the module is installed.
{
...,
"resources": [ "templates/default-template.mustache"]
}
As guifa noted in a comment %?RESOURCES works with individual files, not directory structures. It makes no guarantees of how the files are actually stored. So %?RESOURCES<templates>.dir will not work.

Determining whether a file is linked to a project or not

I'm writing a project documenter and I write out the full file path of each compiled file. This is for the VB.NET language so .proj files are written in xml.
Any file that is linked to the project exists on the same drive so at least one of the directory levels are the same for all files. I currently have it set up to put the project directory path on files which exist inside the project since it only shows the name of the file and the residing directory it lives in if its in a directory inside the project. For files outside (linked in) to the project I initially saw their files paths were "..\..\..\dir\filename". So I set it up to take off all the "..\" and put the necessary directories in front of it and all that worked fine. Now for this one .proj file some of the linked in files have their full file path with no "..\".
How can I properly distinguish these three possible inputs?
System.IO.Path.IsRooted will tell you whether a path is rooted, i.e. is a full path, or not. If the path is not rooted it is a relative path. You can use Path.Combine to resolve the full path from a relative path.

How can I write into a file within an Eclipse bundle?

I have an xml configuration file located into my plugin resources. I want to update this file whenever in the plugin happens some event. I found some methods to find and read the contents of a file located my plugin classpath, but I'm looking for a way to write into such a file.
Is there any way?
Many thanks.
That location (the install directory) is intended to be read-only since it may be shared in a network install scenario. I suggest you instead write the XML file to your plugin's state location which is intended for just this purpose:
String path = Activator.getDefault().getStateLocation().toString();
I should add that this gives you a fully qualified path to the directory created by Eclipse for any files your plugin wants to store. This directory is unique to your plugin.

Intellij Idea problem with text file impossible to read

I have a problem using Intellij Idea.
I am absolutely unable to load text file as InputStream - it doesnt matter where do I put the file (main/java, main/resources...) it just can't find the file - in Eclipse everything works just fine.
I tried setings->compiler->resource patterns and added ?*.txt but that doesn't seem to work either.
Any help is appreciated.
If you load it as a File, make sure that Working Directory is properly set in IDEA Run/Debug Configuration, since it's the default directory where Java will look for a file when you try to access it like new File("file.txt"). Working directory should be set to the directory of your project containing .txt files.
If you load files as a classpath resource, then they should reside somewhere under Source root and will be copied to the classpath according to Settings | Compiler | Resource Patterns.
If you can't get it working, upload your project somewhere including IDEA project files so that we can point to your mistake.
Look at the image, notice that the txt files are in the project root, and not the source folders (in blue).
If you open the Project Structure dialog, and click on Modules and select your module - are the correct folders marked as Source Folders on the sources tab?
Link for how to get to Project Structure dialog
Also, if you print out the absolute path of that file you are trying to read, is that anywhere near where you expect it to be?
An easy way to figure out the same would be to try creating a file in the same fashion and see where it gets created in your project. You can put your input file at the same location and it should work just fine (if it doesn't, you should check your resource pattern which might be causing the file to be not copied over in the build output).
This method actually gives you the working directory of your intellij settings which is pointed out in the accepted answer. Just sharing as I had similar trouble and I figured out this way. :)