CodeIgniter PHPWord template not found - php

I'm facing trouble when using PHPWord with CodeIgniter in loadTemplate always return error "Template Not Found".
I'm using phpword in third party and create Word.php class in library to call it.
My CodeIgniter not a pure one. It already injected like some homemade cms from previous programmer.
My Question is how to I know where is the path of loadTemplate?
Any info needed you can ask me I will provide for you
Thanks,
Hendra

I'm not sure if I understood your scenario, but in any case there is no magic in how the path of loadTemplate works - it works exactly the same as you would access any file with php, i.e. either you place your template file under the phpunit library and use a relative path or you place your file somewhere else and use a full path (or some alias if you have some defined in your server (apache/nginx/..) configuration).

Related

unable to find template, after generating bundle

ok this might be a very strange thing.
it's not the first time I work a symfony project but:
I used the symfony generate:bundle command and after that I created a bundle. Lets call it "CrimeBundle".
I saw it made a folder inside the src/
It also made automatically a DefaultController and an index.html.twig file.
Now whenever I use:
return $this->render('CrimeBundle:Default:index.html.twig');
it doesn't work: I get the error:
Unable to find template "CrimeBundle:Default:index.html.twig" (looked into: /Users/admin/sites/solve/app/Resources/views, /Users/admin/sites/solve/vendor/symfony/symfony/src/Symfony/Bridge/Twig/Resources/views/Form).
however it works whenever I use the namespaced twig path like:
return $this->render('#Crime/Default/index.html.twig');
I like the first option, because on my other projects I use it too. None of them are the same version, currently I use: 3.4.1
Again the file is there, because it works with namespaced twig paths.
I can't understand why return $this->render('CrimeBundle:Default:index.html.twig'); wouldn't work as symfony generated this code.
According to this - https://symfony.com/doc/3.4/templating.html#referencing-templates-in-a-bundle
That's the only reference type the support for bundle templates
#BundleName/directory/filename.html.twig
If you go to docs for symfony 3.1 you'll see that was the last version that supported old reference
AcmeBlogBundle:Blog:index.html.twig
Maybe you can create a pull request for this file
SensioGeneratorBundle/bundle/DefaultController.php.twig

PhpStorm - Cannot find declaration to go to

I try to lookup the declaration of File but PhpStorm says Cannot find declaration to go to.
I also tried it with netbeans, it can't find the declartion too.
I also tried to lookup the alias use File;
I get No usage found in project files.
How does my code even know what it has to do if It can't find any declarations? This makes no sense to me.
How can I find out where File is declared?
How does my code even know what it has to do if It can't find any declarations?
By using an autoloader. This is basically a function which is called whenever an unknown class is referenced, and attempts to define it, usually by including a file according to some naming convention. You will need to find how your particular framework manages this.
Note that it's possible it's including a file from outside the directory you have set up as the "project" in your IDE. Once you've figured out where it is, you may be able to configure your IDE to know about these extra files.
How can I find out where File is declared?
Find a place where the class is used, and using a debugger or just "dump value and die", you can use ReflectionClass::getFilename() to find out about it:
$r = new \ReflectionClass(File::class);
$r->getFilename();
Note that the File::class syntax (available since PHP 5.5) gives you the fully qualified name of the class, ignoring any aliasing or namespace imports.
It's also possible for an extension (a library written in C, not PHP) to define a class. In that case, ReflectionClass::getFilename() will return false, and you'll need to use ReflectionClass::getExtensionName(), then track down the documentation for that extension.
Laravel is quite "opinionated" in the way they use facades.
Apart from the PHPStorm gudelines how to deal with it, I find artisan tinker a simplest IDE-independent way to get familiar with new codebase.
The command provides a REPL shell, so if you are curious of where the File is actually defined, just invoke it, to get some information from the error message:
>>> File::delete()
PHP warning: Missing argument 1 for Illuminate\Filesystem\Filesystem::delete(), called in /path/to/project/app/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php on line 213 and defined in /path/to/project/app/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php on line 118
PHPStrom scans all files in Project Root folder. Add an external library (framework) you use to Project Root folder. Maybe you should instal dependecies via composer.

How does CakePHP connect files in different directories?

This is probably very trivial but because I'm new I just don't get it.
I can see the notion of App::uses at the beginning of every file but how does the file know where App is?
There are no includes anywhere and to my understanding there is one autoloader somewhere in lib, does that mean that one autoloader in one file is responsible for loading all the classes (if instantiated)?
I tried reading this part of the manual but still failed to understand how it works.
Also read some material on the spl_autoload_register function itself but no avail.
I'd really appreciate it if someone could help me understand how the files communicate with eachother.
Look at App::load(), it's doc block explains it:
Method to handle the automatic class loading. It will look for each
class' package defined using App::uses() and with this information it
will resolve the package name to a full path to load the class from.
File name for each class should follow the class name. For instance,
if a class is name MyCustomClass the file name should be
MyCustomClass.php.
And look at the frameworks core file lib/Cake/basics.php:
spl_autoload_register(array('App', 'load'));
It registers that method as auto loader.

Installing Zend Gdata Client library

Hi this is my first post on here. I am trying to install the Gdata Zend Client library without much success.
I have used these resources + scoured Stack Overflow.
https://developers.google.com/gdata/articles/php_client_lib
http://jeromejaglale.com/doc/php/google_calendar_api
I want to be able to add,edit etc events on google calendar via PHP. My problem/question is i really dont understand what the include_path settings are all about and how to set them in order to make the class work. Of course i checked php manual regarding this but still draw a blank.
I have downloaded the relevant class and uploaded it to my web root. In the past i would just include a class by using php include at the top of the page and this would suffice.
I am of the understanding that i need to change the php.ini file to show php where my class is. Does this mean that i have to put my class somewhere else other than the web root.
I am terribly confused about this step and i know that if i can get it installed, actually using the class should be relatively easy.
Thanks for any help.
Welcome! Your Q is about include files rather than ZF elements.
Understanding where the include setting can be made (and subsequently overridden) is an absolute key bit of information.
You need to find out where it is on the server you are working on.
echo ini_get('include_path');
Then dash off and really, really read the corresponding manual page.
Try out including a very simple file with an echo statement, and you will regain your sanity and confidence.
http://www.php.net/manual/en/function.include.php
Get that working then have a play with this:
http://www.php.net/manual/en/function.ini-set.php
The experience how you can include a file from the same directory (not generally a good idea if that is a public webpage - inside your webroot)
Then if you want to really chase this thing down, look at where you can set this in Apache and per-directory in .htaccess files.
Finally, you can just include a file by telling include/require the exact path from the top of the tree;
include /var/www/includes/libraries/and/so/on.php;
There are SO many places you can set and override this that you are really best off finding out where the server thinks the include directory is and putting your compoenents in there:
Now, when that comes to ZF stuff, I (on Deb and Ubuntu anyhow) put the contents of
Zend Framworks version XYZ ZendFramework/lib/Zend <-that folder into:
/usr/share/php/Zend <-into this place
Then setup your autoloader and Robert is your mothers brother...
Zend/Gdata.php line 124 is like this:
public static function import($uri, $client = null,$className=’Zend_Gdata_Feed’)
Change that to this:
public static function import($uri, $client = null,$className=’Zend_Gdata_Feed’, $useObjectMapping = true)

Codeigniter: user defined helper function does not load

I made a custom helper extending the system string_helper.php.
I placed it in my /application/helpers directory, called it MY_string_helper.php as required, unit-tested its functions.
Now, when I try to call one of its functions from a model, it does not work.
The functions in the default string helper work, instead. It looks like my extension is not loaded for some reasons.
Thanks a lot, and happy holidays.
Edit: even funnier. I saved the file as categories_helper.php in the system/helpers directory, and when I try to load it within a model i got the following response: *Unable to load the requested file: helpers/categories_helper.php*
I had the same problem. I came from windows OS development of my codeigniter project, then shifted to Ubuntu, but somehow it still didn't load my helpers.
I found that changing the naming convention to lowercase solves the problem. Don't follow what's written in the doc where you are given a prefix to insert, especially if it's in uppercase. Make use of lowercase.
The Codeigniter User Guide for helpers describes that helpers are available to controllers and views only. It does not explicitly mention that helper functions work in models.
CodeIgniter does not load Helper Files
by default, so the first step in using
a Helper is to load it. Once loaded,
it becomes globally available in your
controller and views.
Linux is case sensitive, Windows no. So, if you are development in OS Windows, before upload your system in a Linux hosting foe example, you need have the names of the files in lowcase.
For example:
In Windows: application/helpers/MY_functions_helpers.php
In Linux: application/helpers/my_functions_helpers.php
mmm, i'm not sure it will work for helpers, but have you tried to load the helper in this way?
$CI = & get_instance();
$CI->load->helper('string');
I faced a similar kind of situation. My development environment was WINDOWS and it worked fine as described in the DOCs i.e. MY_string_helper.php
On the production environment of UNIX, it gave error:
Unable to load the requested file: helpers/my_form_helper.php
Changing the file name to lower case resolved this error BUT the helper was not actually loaded.
After a lot of time waste, by hit and trail it worked [ it is un-documented ]
In the autoload.php, just include the mention the extended helper before the default helper:
$autoload['helper'] = array('my_string', 'string');
Also, the prefix has to capital, it did not work with lower case prefix:
$config['subclass_prefix'] = 'MY_';
you just have to change your helper function name with your prefix like found in application/config/config.php
after helper renamed make sure it contains small letters only
then change autoload file with the function name that you renamed,
main problem because of OS like your Hosting server is linux and you develope with windows so this problem rise

Categories