Use PHPDocumentor to create an Eclipse Library - php

I have an unusual request,
I'm working on PHP 5.3, my IDE is Eclipse and I need help setting a file like the one that comes in default with the php functions, so I can use it for code completion and I can have the documentation on hover.
So basically, I have a library, which I want to pull the declarations for everything (function, classes, etc) and the PHPDoc block, and use them to create a new file, which will be added as a library on Eclipse on the include path. Anyone knows an automatic way to do it?
EDIT: To explain a bit better what I want to do. I want to run a script that will do almost what PHPDoc does, but instead of creating a set of html files after load a file, it will create a copy of the php file which only has the declarations and comments. So that file can be given to the programmers, instead of the full library with source-code.
I though about using the ReflecationClass, by including each file, check the defined class\functions and then writing the new file, but that means that all the includes\requires need to happen in order, something I can't guarantee

Not sure if this counts as "automatic", but what you describe sounds like it can be roughly accomplished by having this library itself as an open Eclipse project. If your "new code" is in a separate Eclipse project, then you want to list your library project in the new project's Include Path configuration.
In the "PHP Include Path" config popup for your new project, click "Add" and select the library project (it will only be visible here if it is also "open"). You can choose whether or not it should come before the new project on the include path or not by moving things around in the Order tab. I tend to keep my current project listed first, then dependencies afterward, just in case any of my new project's classes take precedence over same name classes in the dependency projects.
An added benefit to this is that when you open your new project, any referenced projects in the Include Path configuration will automatically be opened too.

Related

How/Where does SuiteCRM compile the scss files in a theme?

I'm currently working on setting up a custom admin page for a specific task I need to do and it requires some custom styling in the theme. I went to the themes/SuiteP/css folder and found admin.scss. After making a change, I had assumed that Suite would dynamically compile the asset since I am developer mode; however, that did not happen.
I decided to search the code for any place I could find that would deal with compiling those files to *.css, but found no such place.
My question involves inquiring as to where that compilation takes place and/or how it takes place. Right now it appears as if I have to manually compile those assets, which seems pointless because it is just an extra step I have to manually take, rendering using SCSS less useful in comparison with CSS.
Right now, my solution will probably have to be adding a CSS file that has nothing to do with whatever pipeline exists, but if I can leverage existing functionality, that would great.
Due to legacy issues with the SugarCRM framework, SuiteCRM loads style.css for current theme. The sass work for SuiteCRM is in a transitioning period. It is currently a manual process, but we hope to make it automated in the future.
We are using Sass as a way to allow developers to customise the SuiteP theme. I have a github project which provides a UI to generate the variables.scss for you. I am hoping that it will be accepted in a future release.
So in regards to your workflow you only need to care about the style.css.
If you want to contribute back to the SuiteCRM project, then you will need to use the sass files in themes/SuiteP/css/.
However, if this is just for your instance of SuiteCRM, then you will want to create a style.css in the custom/themes/SuiteP/css/style.css. How you change that is up to you.
I would recommend that you use Sass to generate the style.css.
You can achieve this by copying the style.scss file custom/themes/SuiteP/css and then add the following to the file
#import ../../../../themes/SuiteP/css/style.scss
Note: I may have the path slightly wrong
or use the command line tools to include the themes/SuiteP/css/ directory
See for details:
SASS: Import a file from a different directory?
SuiteCRM should pick up the rest of the work. There is a change in SuiteCRM 7.9 that deprecates the $sugarcrm_version in favour of $suitecrm_version. This will effect theme themedef.php.
See for details
https://github.com/salesagility/SuiteCRM/pull/3233/files
I hope this answers your question.

php includes inside other includes

So my login check I have split into two sections that I tried putting in two different files and including them. First I will show the original code then the split code. I think my problem is with the link to the include. I try to use an absolute path. But it seems to be failing. My whole App is modular so I have global files set up outside of the rest of the App structure and I call the files as needed. I have also thought of just loading the functions through _autoload() but I don't know that this would solve my issue.
<?
//Inventory index.php
include$_SERVER['DOCUMENT_ROOT'].'/Globals/db_connect.php';
include$_SERVER['DOCUMENT_ROOT'].'/Globals/functions.php';
sec_session_start();if(login_check($mysqli)==true){?>
/////Html and or more php code to be executed. Usualy a mix of both.
<?}else{
echo ("You are not authorized to access this page, please login. <br/>");}?>
here is what I am trying to do....P.S. I know my code is kinda hard to read I am trying to format it for easier reading but I can process clumps better than I can spaced code. Not sure why.
<?
//Inventory index.php
include$_SERVER['DOCUMENT_ROOT'].'/Globals/auth1.php';?>
/////Html and or more php code to be executed. Usualy a mix of both.
<?}else{include$_SERVER['DOCUMENT_ROOT'].'/Globals/auth2.php';?>
What I think is happening is the includes in Auth1 are failing. are my absolute paths failing? Am I better off using _autoload().
You should always choose "autoloading" in favor of manual includes for multiple reasons.
Readable structure -- one class for each file and one folder for each namespace segment allows you to find anything in the directory structure of your project very fast.
Easy maintenance -- if you change the folder structure/position of your files (as well as their namespaces) you're done, no paths to be rewritten and verified.
Compatibility with other projects for example using PSR-0 or PSR-4. PSR-0 is meant for covering legacy code, PSR-4 should be used for new libraries.
Compatibility with package management software -- which expect some kind of predictable conventions to be respected. For example Composer expects either PSR-0 or PSR-4 and it enables autoloads for you.
On the subject of coding standards and formatting the same applies:
familiar structures are easier to recognize.
The decision is perfectly arbitrary; it's always your (or your team') choice. Either will work fine -- you will get used to any one of them.
Consistence is important, PSR-1 and PSR-2 are the lingua franca of both Symfony & friends as well as many other projects which use composer as their package management (and others).
I can suggest to use composer and it's autoloader which support different types of files loading. For production you can use --optimize option to make autoloading works better (as I remember composer scan all folders and build array of existing files)

Automatic re-compilation with asset management tools

I have been looking into incorporating an asset management/pipelining tool (probably Assetic) into my PHP project.
Since assets can be grouped into collections or wildcard-based paths using such tools, if I wanted to set up a watch process that re-compiled/minified only those source files that had changed, how would I do that given that assets have to be looked up by name (see example below)?
(I noticed that for Symfony there's a watch task for Assetic but I'm not sure that it re-compiles only the changed file(s) and also I would have to make it work outside of Symfony since my app uses the CodeIgniter framework.)
In Assetic, you can create a wildcard-based asset, e.g.:
new GlobAsset('/path/to/compass-sources/*')
You can tell it to send the assets through a filter (Compass in this example) and then output the result (CSS) to a folder like public/css.
Let's say I set up the watch process using node.js's fs.watch so that I can theoretically tell Assetic to re-compile a particular asset whenever one of its source files changes.
Since my node.js script would only know the name of the actual file that changed (e.g. compass-sources/layout.scss), how could I look up which AssetCollection or GlobAsset that particular file belonged to (say an asset called global-styles) in order to recompile it?
I'm open to alternatives here. I looked at grunt and may very well use grunt-contrib-watch to handle the file watching, but I like the idea of using Assetic because the project is in PHP and I think that will be easier on future PHP developers working on the system who may not be familiar with node.js. It seems grunt take a different approach where assets don't necessarily go in named bundles. Mostly I want to understand the conceptual approach of named asset bundles (like in Assetic) as it relates to my goal of recompiling assets whenever the source files change.

Netbeans: Creating a Project Concept versus Opening Files

I'm having a little trouble understanding a couple of concepts.
I am new to Netbeans and using it for PHP development. I am previously using JEdit. In JEdit, I just simply open the file browser and start editing files.
In Netbeans, it wants me to create projects and import files.
My questions are:
When I import a project, it sets up data files that Netbeans needs and leaves the original directory in tact, correct? I noticed I could open and edit a project and it affected the original.
Sometimes I like to quickly switch between projects and just want to view the /www/ directory of my wamp server to grab files, look at past projects, etc. Why can't I simply do this? (must I always import projects to see my /www/ folder)
What is the point between creating a project versus just opening files?
Thanks all!
The point of creating a project vs just opening files in an editor is that Netbeans knows that all these files go together. They are part of the same project. That allows you, for instance, to refactor function names or class names and have Netbeans automatically apply the changes everywhere those are used within your project.
If you create a project from existing sources, those existing files will be the ones you're editing. If you have your files under version control, you can simply create a Netbeans project in the directory where you checked out your code. You can then do commits and all from within Netbeans.

Inside Eclipse PDT whats the purpose of "PHP include path" in project properties?

Was wondering when we right click on project folder in php explorer then there is an option "Php include path" it does not edit include_path property of php.ini . Hence even specifying include path using this option it does no different to project then whats its purpose of it??
Its is used to link two projects together within eclipse. If one project includes code from another project, eclipse is not aware of the connection and only evaluates the code with the project you are in. So if you try and use a function from another project for example, there would be no auto complete etc for that function.
By adding the second project to your include_path you are telling eclipse that you are using that project and all that projects classes, functions etc will be added to the auto complete and documentation prompt.
You are still required to connect the two by code.
The webserver (more accurate: The interpreter process created by the webserver) cannot know, that you even use an IDE to write your scripts, so its also impossible for it to know the project settings. If you execute it from within eclipse, it provides a custom php.ini, that contains the given include-path.

Categories