Change composer global path (Windows) - php

Composer uses %APPDATA%\Composer directory by default for global packages.
So I need to add %APPDATA%\Composer\vendor\bin path to my user PATH environment variable.
Can I change installation directory to something like C:\php\composer? How can I do it?

On Windows, when global install of a library / package is done, composer stores the package in a Composer directory inside windows **application data folders** which by default is C:\Users{user name}\AppData\Roaming`.
To change this folder to say C:\php\composer, create a COMPOSER_HOME environmental variable with the value set to C:\php\composer.
The steps below explain how environmental variables are added in Windows. * Press Windows Key + Pause Break then click Advanced system Settings
(source: w3guy.com)
Click the Environmental variables button.
(source: w3guy.com)
Under System variables, click New... button and add the environmental variable like so:
(source: w3guy.com)
You might want to restart your PC for this to take effect.
Credit: http://w3guy.com/change-composer-global-package-install-folder-windows/

I found an answer in the source code: https://github.com/composer/composer/blob/master/src/Composer/Factory.php#L45
So environment variable COMPOSER_HOME must be defined as C:\php\composer.

Go to folder
(C:\Users(your user)\AppData\Roaming\Composer )
Then create new folder (vendor)
and
in vendor create (bin) and copy (C:\composer\composer.phar) to (bin) .

Related

realpath() doesnt show realpath GitLab ci runner

the code is stored in /var/www/abc -- "CodePath"
when running gitlab-ci (runner), the code is called via /home/gitlab-runner/builds/4v8bC1n9/0/_gitlabgroup_/_gitprojectname_/abc -- "RealPath"
I'm using a local runner and a shell execution.
when I use the realpath() function in my php code, it still shows the "CodePath" when using gitlab ci runner, instead of "RealPath".
How can I get the "RealPath" integrated in my code, or reconfig GitLab to use the "CodePath" instead?
The runner cli options are documented here: https://docs.gitlab.com/runner/executors/shell.html#overview
The path where the job is run and your sources are cloned into is available in the environment variable:
CI_PROJECT_DIR
The full path where the repository is cloned and where the job is run. If the GitLab Runner builds_dir parameter is set, this variable is set relative to the value of builds_dir. For more information, see Advanced configuration for GitLab Runner.
You did no state how you use realpath(path)...
Whilst a path must be supplied, the value can be an empty string. In this case, the value is interpreted as the current directory.
So maybe you hardcode chdir('/var/www/abc'); somewhere?
When you do chdir(getenv('CI_PROJECT_DIR')); before you call realpath() - it should use the CI directory. Assuming you use realpath without a parameter.
Also: maybe you can make some changes and use one of the the built in constants for the current directory: https://www.php.net/manual/en/language.constants.predefined.php
Thanks to madflow's mentioning of the variable I managed to figure out the following:
runners specific configuration files exist and can be configured as described here
I needed to do these things:
specify enable the [runners.custom_build_dir] section in the config.toml
[[runners]]
builds_dir = "/var/www/abc"
[runners.custom_build_dir]
enabled = true
(boolean not in quotes)
specify a variable in my yml
variables:
GIT_CLONE_PATH: $CI_BUILDS_DIR/
on os level there was some privilege setting for the dir required, where I went for quick and dirty 777 on my local machine

phalcon installed components or not coming in cmd windows opertaing system

I have installed the phalcon in windows by adding phalcon_dll to xampp/php/ext and added extension in php.ini file now when i checked whether it installed or not i did <?php phpinfo(); ?> then i can able to see that it is installed..
Now i want to create a new skelton application through cmd when i type phalcon it should show the components as per documentation but its sayin this:
C:\Users\Amerytrech-Waheed>phalcon
'phalcon' is not recognized as an internal or external command,
operable program or batch file.
im tryig do like this: https://www.tutorialspoint.com/phalcon/phalcon_environmental_setup.htm
but little confused what are all need to add in system variables.?
and what is the alternate solution to create skelton?
Step 5 in the very document you pasted states:
After downloading the package, set the path variable in the system properties
it then explicitly shows you an image that shows the path to add, separated by a semicolon.
;C:\phalcon-devtools-master
So if you are unclear on where to set this.
Right click Computer -> Properties -> Advanced -> Environment Variables -> Path then add the path mentioned above to the very end of the path string.

Class Config conflict in XAMPP xamppfiles/lib/php/config.php

What is xamppfiles/lib/php for?
And I see that path is in PHP's include_path but it's not set in php.ini so I guess XAMPP includes it internally.
What do those php files do and why are they included by default?
I just installed an application that does include('config.php'); trying to reference a file from the same directory it's in, but ends up including xamppfiles/lib/php/config.php instead and has a name clash with class Config.
How can I avoid including XAMPP's php files or otherwise avoid this problem?
You can remove the "Config" pear package that comes with XAMPP. This package ships the "Config.php" file that uses the same name that your application.
sudo xamppfiles/bin/pear uninstall Config

How to add project to Netbeans when all source files are not in webroot?

The directory structure of my project is like this:-
/var/www/includes/
/var/www/classes/
/var/www/public/css/
/var/www/public/js/
/var/www/public/index.php
The webroot is /var/www/public, so accessing the test domain localhost.dev would serve the files inside the public directory and hence would run /var/www/public/index.php. No need to access like localhost.dev/public/index.php
The problem is when I create the project in Netbeans, I have to set the index file so that the project can be debugged using xdebug and Netbeans.
So when adding the project I provided /var/www as Project source folder (Sources Folder) as the includes and classes are in this folder. In the next project configuration screen (Choose Project > Name and Location > file path is taken as Run Configuration), I'm asked for the Project URL and the index file. Since the index.php file is actually under the /var/www/public/, when I browse the file and select it, the url to index page is taken as localhost.dev/public/index.php instead of just localhost.dev/index.php. This is preventing me from debugging the project.
Can anyone please point out how to add projects to Netbeans when all the source files are not in web root and the project is to be debugged using xdebug.
I think its a bad practice to put all the project files directly in /var/www.
I think you will never see that in real deployed projects. So my first recommendation will be to change the way you are structuring your project. If that's not possible, in Netbeans select /var/www/public as the Project folder.
If Netbeans need references to the folders in /var/www, create symbolic folders inside public pointing to those in /var/www.
The last resource you have is to create a rewrite rule in Apache to make localhost.dev/public be the same as localhost.dev. You can look for this in Apache documentation.
I have a similar set up with one minor difference: my setup uses a remote site on my local development server. On the "Run Configuration" window of the project properties, I set "Run As" to "Remote Web Site (FTP, SFTP)". I don't think this affects the information in my answer, but I'm mentioning it just in case.
Go to the "Sources" window of your project properties, find the entry for "Web Root", click "Browse" and select the /var/www/public directory. That should cause xDebug to use localhost.dev/index.php. You'll notice when you go to the "Run Configuration" window and browse for the Index File that the browse window will start in "public" rather than "www".
An important note about this type of configuration that caused me a great deal of frustration.
When using xDebug, you'll want to be able to set breakpoints in and work with the files outside of the web root (public) directory. Because you've set the web root to /var/www/public, you won't be able to work with the files in /var/www/includes or /var/www/classes.
The thing you need to do is to add the files outside of your web root to the Global Include Path.
There are two methods for adding directories to your Global Include Path, which one you use depends on how you've configured your project.
In your case, the external directories are included in your project, so you need to add them via the "Options" interface. Go to Tools->Options and select the "PHP" tab, then add the /var/www/includes and /var/www/classes folders to the Global Include Path.
The other method for adding files to the Global Include Path is for files that are located outside of your project source folder. For directories like /var/folder_outside_www/, you use the "PHP Include Path" window in the project properties.
I haven't found a better way but I use this steps:
Menu:Project Properties -> Link:Run Configuration -> Button:Advanced
Debug URL, choose: Ask Every Time
Path Mapping, Server Path: http://localhost.dev/ ,Project Path: /var/www/public/
Now, when you start Debugging process, Netbeans will display Specify URL pop-up which you can change from http://localhost.dev/public/index.php into http://localhost.dev/index.php
Set /var/www/public as project folder (contain netbeans project folder) and include in project properties /var/www/includes/ and /var/www/classes/ as global include directories. Or best way use PHPStorm.

failing to include the path in php.ini

I am trying to include this path to the zend framework, but failing:
include_path = ".;C:\ZendFramework-1.11.11\ZendFramework-1.11.11\library"
should the Zendframework reside in a different folder?
UPDATE
It works now.. I typed zf show version.
I want to set the thing to as an environmental variable, which means that no matter from where I will type the command in the command line... zf show version will work..
I went to to the environment variables by clicking the right button on my computer, and then navigating to Environment variable and setting the path like this.
zf show version
variable name: Temp
variable path: %USERPROFILE%\Local Settings\Temp;C:\xampp\php;
Basically, I want to set C:\xampp\php as a default so that I wont need to navigate to the directory each time i start the command line
No, Zendframework doesn't have to reside in a different folder.
Your include_path is right and should has worked.
Is it that your path Zend library path is not right?
what is the error your got?

Categories