Before you answer let me explain. It works fine with local projects LOCALLY but not over FTP even with PHP class files are in the same directory.
For example if I have a file I'm including using require 'happyclass.php'; in my index.php file and I want to use a class that's in happyclass called happy I can do something like
$happy = new happy();
it will suggest the class and also autocompelte and auto-show PUBLIC METHODS AND FIELDS ETC OF THAT CLASS!
So for example say there was a public method called beHappy() in the happy class then when I did this
$happy->
The problem would still auto-show beHappy() as a public method of that class and suggest it. All I have to do is press enter.
This works fine locally but NOT IF I'M USING THE CONNECTIONS MANAGER for FTP built into aptana. My workaround has been using synchronization from local to remote but this is annoying and seems unnecessary.
What can I do? Thanks for the help guys!
That how I get it to work:
create new project make sure PHP.
Right click on project icon.
PHP Buildpath - click add and choose folder witch all your classes.
OK
Bit lower Project Natures makes sure PHP is Primary;
OK
sometimes restart Aptana 3 and autocomplete working fine;
Related
EDIT: Question title changed. The original question title was: Using a relative URL in a Vue app that works in both production and development, but this turned out not to be the cause of my problem (see comments below).
I've tried so many things and all I want to do is use a single relative url in a JavaScript fetch() method and have it run consistently in both development and production without having to change lots of config files or webpack settings.
In a nutshell I want to fetch() a get-users.php file which resides in the same directory as the app — nothing fancy or complicated — just a php file that gets some data from a mysql database on the same host.
I can make it work in development, but then it fails in production (npm run build), OR I can get it working in production but then it fails in development (npm run serve). The reason it fails is essentially because the relative url in production is the root of the dist folder, but the relative url in development is the root of the vue project folder — is that correct?. So in development for example I can use fetch(public/get-users.php) which works perfectly, but then in production the dist folder doesn't contain a public folder so I get a 404 error. I can manually copy and paste the public folder to the dist folder after each build, but this just seems like an unnecessary extra step.
Part of the problem is that I don't fully understand where a file like get-users.php should reside. I don't mind if I have to put it in the public or static folders, but when I do that it fails in production because of the example above. Could someone please explain the role of the public folder in a Vue CLI app please? Does it do something under the hood that I don't fully understand? Am I missing something obvious? It seems like such a trivial task to make this work but I'm banging my head against the wall here! Please help! :)
If you're using vue cli then all you need is to put your get-users.php file inside the public folder and access this file without public prefix like this:
fetch('get-users.php')
This will work as expected for both dev and prod environments because during the build step webpack will copy all static assets from the public to the dist folder.
I'm trying to migrate from PHP Storm to VS Code but there's a little issue that is bothering me.
I'm using PHP Intellisense (tryied Intelliphense too), configured it as the instructions asked (I Have PHP 7.2 and PATH set correctly), my project was opened as a folder.
So here's whats going on (examples):
require('incs/DB.php');
$con=new DB(configs,goes,here);
DB included and configured to use. If I try to type: "$con->" suggestions appear as they should (GREAT!)
Now another file:
index.php
require("config.php");
...more code...
If in this file I try to type "$con->" nothing that matters shows up. The suggestions have nothing to do with the class "$con" is using.
So, did I make something wrong or is this a common thing in the extension? Can I only call for suggestions on the same file that "created" the class?
This used to work, but it stopped working recently. I don't think anything changed in my settings, but I have poured over them for a couple hours now just to make sure. I have checked all over google and SO too. Please pay attention to the details before claiming "this was answered over here..." Thanks. :)
Assumptions and Requirements
Assume we have two files:
<project_root>/index.php
<project_root>/folder/file.php
Assume our project root is /home/me/project.
We want to include file.php from index.php. We expect PhpStorm to be able to resolve the file path and allow us to do nifty IDE things like "Go To Declaration."
What works
require 'folder/file.php';
require '/home/me/project/folder/file.php';
$root = '/home/me/project/';
require $root.'folder/file.php';
What No Longer Works
define('ROOT_DIR', "/home/me/project/");
require ROOT_DIR.'folder/file.php';
PhpStorm does recognize the value of ROOT_DIR when I mouseover, but it highlights home and says something like: Path '"/home/me...folder/file.php' not found
Why Use a Constant Anyway?
To keep this simple, I've left out details that are not necessary to illustrate the problem. The primary thing I'd like to address is why this used to work but no longer does, and/or how can I make it work again.
Sorry, can't help. What are you really trying to do?
Here are the details I left out. If we can't solve the primary issue, perhaps we can find a good work around.
I'm working with an existing codebase. Most files require a config.php file that defines root_dir() for getting the web/project root. PhpStorm wasn't resolving those paths (understandably so), so I created a constant to takes it's place. That makes more sense anyway.
In today's battle, I discovered that you can do this:
/** #define "root_dir()" "/home/me/project/" */
// or
/** #define "ROOT_DIR" "/home/me/project/" */
If you put that anywhere in the file then PhpStorm is able to resolve all the includes/requires in that file. BUT, it only works in that file, even if you try to include/require it in another file. You'd have to do this to EVERY file to get it working everywhere. Nope. Nuh-uh. No thank you. I need to reference the absolute path to the project/web root in a way that PhpStorm will recognize across the whole project.
#LazyOne answered this in the comments. This is a bug in the latest release, and it's being tracked here: https://youtrack.jetbrains.com/issue/WI-31754
Until this gets patched I've created this work around:
Using Keyboard Maestro, I created a hotkey that will paste the #define comment at the top of the file and return the cursor to its original position. Download the macro here. Import that and edit the text.
Edit: You may actually need to edit the file in a regular text editor. One of the file paths may need to be changed to work on your system.
Note: I'm using a modified version of the Mac Eclipse keyboard layout in PHPStorm. I'm not sure that will matter.
Also, be aware that many of your "changed files" will simply have this mapping at the top of the file, and this mapping may not be correct for you teammates. I'm simply excluding those changes from my commits.
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)
I'm struggling to get the Yii crud tool to work for me. I'm using Gii and this is the error I'm getting in my log file:
PHP Fatal error: Cannot redeclare class CController in /var/www/includes/framework/web/CController.php on line 77
These are the only steps I have taken:
1) Downloaded yii and extracted 'framework' into /var/www/includes
1.5) Created a table called me in my database [EDIT]
2) Executed /var/www/framework/yiic webapp /var/www/web
3) uncommented 'gii'=>array(....) in config/main.php
3.5) Added my database configurations [EDIT]
4) Browsed to http:///index.php?r=gii
5) Navigated through Model generator to create 'me'
6) Navigated through Crud generator using me
7) Browsed to http:///index.php?r=me
Any ideas? I've spent ages on this and now I'm rather annoyed. :(
Thanks for your help in advance.
It looks like you have the framework in /var/www/framework/ AND /var/www/includes/framework/. Thus it is being included twice and you get an error that you are declaring the class twice. Remove the second copy from the /includes folder and stick with the one in /www. It's also best practice to make sure your framework folder is not accessible from the web.
I'm not sure why this worked but it did.
I simply renamed the framework directory to yii and it worked. I did nothing else.
This has confused me but at least it now works.