Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Support for Phalcon v5 #1541

Open
wants to merge 1 commit into
base: 5.0.x
Choose a base branch
from
Open

Conversation

rudiservo
Copy link
Contributor

Hello!

In raising this pull request, I confirm the following (please check boxes):

  • I have read and understood the Contributing Guidelines
  • I have checked that another pull request for this purpose does not exist
  • I wrote some tests for this PR

Small description of change:
Changelog and a link update to make official the support for phalcon v5

Thanks

@codecov
Copy link

codecov bot commented Sep 4, 2023

Codecov Report

Merging #1541 (c485fe0) into 5.0.x (2e16ea6) will not change coverage.
The diff coverage is n/a.

Additional details and impacted files
@@          Coverage Diff          @@
##           5.0.x   #1541   +/-   ##
=====================================
  Coverage   4.45%   4.45%           
=====================================
  Files         82      82           
  Lines       3995    3995           
=====================================
  Hits         178     178           
  Misses      3817    3817           

@r-martins
Copy link

How could I use your PR in my project?
I was able to require it by modifying composer.json as follows

{
    "repositories": [
        {
            "type":"package",
            "package": {
                "name": "rudiservo/phalcon-devtools",
                "version":"5.0",
                "source": {
                    "url": "https://github.com/rudiservo/phalcon-devtools.git",
                    "type": "git",
                    "reference":"5.0.x"
                }
            }
        }
    ],
    "require-dev": {
        "rudiservo/phalcon-devtools": "5.0.x"
    }
}

I also ran vendor/rudiservo/phalcon-devtools/phalcon.sh and source /root/.bashrc but when I type phalcon in the root of my project it just spits the whole thing...

root@16c64d6ef568:/var/www/html# phalcon
#
# This file is part of the Phalcon Framework.
#
# (c) Phalcon Team <[email protected]>
#
# For the full copyright and license information, please view the
# LICENSE.txt file that was distributed with this source code.

PURPLE="\033[0;35m"
GREEN="\033[0;32m"
YELLOW="\033[1;33m"
NC="\033[0m"
DIR=
IS_BASH=0
SOURCE_FILE=

init(){
        source=`echo $0 | grep "bash"`

        if [ "$source" == "bash" ]; then
                DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
                IS_BASH=1
        else
                DIR=$( cd -P -- "$( dirname -- "$0" )" && pwd -P )
        fi

        DIR=${DIR%/}
}

alter_profile(){
        export PTOOLSPATH="$DIR/"
        export PATH="$PATH:$DIR"

        PTOOLSVAR="export PTOOLSPATH=${DIR}/"
        PATHVAR="export PATH=\$PATH:$DIR"

        if [ -e $HOME/.bash_profile ]; then
                echo "$PTOOLSVAR" >> $HOME/.bash_profile
                echo "$PATHVAR" >> $HOME/.bash_profile
                SOURCE_FILE=$HOME/.bash_profile

                source ${SOURCE_FILE}
        elif [ -e $HOME/.bashrc ]; then
                echo "$PTOOLSVAR" >> $HOME/.bashrc
                echo "$PATHVAR" >> $HOME/.bashrc
                SOURCE_FILE=$HOME/.bashrc

                source ${SOURCE_FILE}
        elif [ -e $HOME/.profile ]; then
                echo "$PTOOLSVAR" >> $HOME/.profile
                echo "$PATHVAR" >> $HOME/.profile
                SOURCE_FILE=$HOME/.profile

                source ${SOURCE_FILE}
        elif [ -e $HOME/.zshrc ]; then
                echo "$PTOOLSVAR" >> $HOME/.zshrc
                echo "$PATHVAR" >> $HOME/.zshrc
                SOURCE_FILE=$HOME/.bashrc

                source ${SOURCE_FILE}
        elif [ -e $HOME/.cshrc ]; then
                echo "setenv PTOOLSPATH ${DIR}/" >> $HOME/.cshrc
                echo "setenv PATH \${PATH}:$DIR" >> $HOME/.cshrc
                SOURCE_FILE=$HOME/.cshrc

                source ${SOURCE_FILE}
        else
                printf "\n${PURPLE}No bash profile detected. Environment vars might disappear on console restart!${NC}\n"
                return 0
        fi
}

check_bash(){
        if [ "$IS_BASH" == 0 ] && [ ! -z "$SOURCE_FILE" ]; then
                printf "\nTo start using Phalcon Developer Tools you need to run 'source ${SOURCE_FILE}'"
                printf "\n"
        fi

        printf "\n"
}

check_install(){
        if [ -z "$PTOOLSPATH" ]; then
                printf "\n${YELLOW}Phalcon Developer Tools Installer${NC}"
                printf "\n"
                printf "\n${PURPLE}Make sure phalcon.sh is in the same dir as phalcon file${NC}"
                printf "\n${PURPLE}and that you are running this with sudo or as root.${NC}"
                printf "\n"
                printf "\nInstalling Devtools..."
                printf "\nWorking dir is: ${DIR}"

                devtools="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

                if [ -f ${devtools}/phalcon ]; then
                        printf "\nFailed to create symbolic link ${devtools}/phalcon: File exists"
                        printf "\nExit.\n\n"
                        return 1
                fi

                alter_profile

                if [ ! -L ${devtools}/phalcon ]; then
                        printf "\nGenerating symlink..."
                        ln -s ${devtools}/phalcon.sh ${devtools}/phalcon
                        chmod +x ${devtools}/phalcon
                        printf "\n\nDone. Phalcon Developer Tools installed!"
                        printf "\nThank you for using Phalcon Developer Tools!"
                        printf "\nWe hope that Phalcon Developer Tools helps to make your life easier."
                        printf "\n"
                        printf "\nIn case of problems: "
                        printf "${YELLOW}https://github.com/phalcon/phalcon-devtools/issues${NC} "
                        printf "\n                and: ${YELLOW}https://forum.phalcon.io${NC}"
                        printf "\n"

                        check_bash

                        return 0
                fi
                return 1
        else
                devtools=${PTOOLSPATH%/}
                if [ "${devtools}" != "${DIR}" ]; then
                        printf "\n${PURPLE}Your environment variable \$PTOOLSPATH is outdated!${NC}"
                        printf "\n${PURPLE}Current value: $devtools${NC}"
                        printf "\n${PURPLE}New value: $DIR${NC}"
                        printf "\nExit.\n\n"
                        return 1
                fi
        fi
        return 0
}

init

if check_install; then
        devtools=${PTOOLSPATH%/}
        php "$devtools/phalcon" $*
fi

@rudiservo
Copy link
Contributor Author

hey, my file changes are minimal, the current phalcon/phalcon-devtools 5.0.x has the necessary PR for 5.0.x compatibility.

the README in the project has the way to do it with git.
https://github.com/phalcon/phalcon-devtools#installation-via-git

@r-martins
Copy link

r-martins commented Sep 26, 2023

hey, my file changes are minimal, the current phalcon/phalcon-devtools 5.0.x has the necessary PR for 5.0.x compatibility.

the README in the project has the way to do it with git. https://github.com/phalcon/phalcon-devtools#installation-via-git

Thanks for the reply.
I did that with composer global require phalcon/devtools:5.0.x-dev -W

I can see the global is using phalcon/devtools 5.0.x-dev 2e16ea6 but when I run phalcon from the project's root folder, I get an error:

Fatal error: Uncaught TypeError: strtolower(): Argument #1 ($string) must be of type string, bool given in /root/.composer/vendor/phalcon/devtools/bootstrap/autoload.php on line 40

Tried to fix with an export PTOOLSPATH=/root/.composer/vendor/phalcon/devtools but other errors also continue to occur when creating a controller for example..

$ phalcon create-controller hello

Phalcon DevTools (5.0.0)

Info: This command must be run inside a Phalcon project with a .phalcon directory. One was not found at /var/www/html

Info: Shall I create the .phalcon directory now? (y/n)

y

Retrying command...

Warning: mkdir(): File exists in /root/.composer/vendor/phalcon/devtools/src/Commands/DotPhalconMissingException.php on line 61

Call Stack:
0.0003 410536 1. {main}() /root/.composer/vendor/bin/phalcon:0
0.0005 422264 2. include('/root/.composer/vendor/phalcon/devtools/phalcon') /root/.composer/vendor/bin/phalcon:119
0.0093 1078704 3. Phalcon\DevTools\Commands\DotPhalconMissingException->promptResolution() /root/.composer/vendor/phalcon/devtools/phalcon:66
1.4498 1078768 4. Phalcon\DevTools\Commands\DotPhalconMissingException->resolve() /root/.composer/vendor/phalcon/devtools/src/Commands/DotPhalconMissingException.php:54
1.4498 1078816 5. mkdir($directory = '/var/www/html/.phalcon') /root/.composer/vendor/phalcon/devtools/src/Commands/DotPhalconMissingException.php:61

Fatal error: Uncaught Phalcon\DevTools\Commands\DotPhalconMissingException: This command must be run inside a Phalcon project with a .phalcon directory. in /root/.composer/vendor/phalcon/devtools/src/Commands/CommandsListener.php on line 51

Phalcon\DevTools\Commands\DotPhalconMissingException: This command must be run inside a Phalcon project with a .phalcon directory. in /root/.composer/vendor/phalcon/devtools/src/Commands/CommandsListener.php on line 51

PS: It actually works if the project was created with devtools. Thanks for the help anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants