Giter Site home page Giter Site logo

anandpilania / php-android-cli Goto Github PK

View Code? Open in Web Editor NEW
20.0 4.0 9.0 229 KB

Create Android-Studio gradle project from CLI with PHP... (created for personal use)

License: MIT License

PHP 100.00%
android-app php cli gradle scaffolding skeleton android-cli php-cli

php-android-cli's Introduction

PHP Android CLI

Hits

PHP Android CLI create/generate Scaffold Android-Studio Gradle project with:

  • Java or Kotlin language,
  • legacy or standard package
  • Modules (application/library)
  • Variants with Dimensions
  • Scaffold project & application/library level build.gradle with package name & dimensions & variants
  • Manage settings.gradle
  • Generate manifest file & res with default icon, color, style & values
  • ...

New Features!

  • Language select java or kotlin
  • Version legacy or standard

Removed!

  • androidX selection,
  • jetifier selection,

You can also:

  • set targetSdk
  • set buildToolsVersion
  • set minSdk & maxSdk
  • JAVA or KOTLIN
  • legacy

Tech

PHP Android CLI uses:

And of course PHP Android CLI itself is open source with a public repository on GitHub.

Installation

PHP Android CLI requires PHP v5+ to run.

Just download the phpandroid and start scaffolding.

$ phpandroid create <PROJECT_NAME> <PACKAGE> [OPTIONS]

USAGE

Basic use

Create HelloWorld project with com.example.helloworld package name:

phpandroid create HelloWorld com.example.helloworld

Create Modules along with App

Create HelloWorld project with sdk library & admin application

phpandroid create HelloWorld com.example.helloworld --modules=sdk:library,admin

Create productVariants: free & paid variant

phpandroid create HelloWorld com.example.helloworld --variants=free:type,paid:type

here type is the dimension

Options

Default

PHP Android CLI is currently using default values for latest Android. These are:

OPTIONS Usage DEFAULT
--type/-t set type kotlin
--legacy/-l set legacy false
--compileSdk/-cs set targetSdk 31
--buildTools/-bt set buildToolsVersion 31.0.0
--minSdk/-ms set minSdk 21
--targetSdk/-ts set maxSdk 31

Use --force to re-write existing project.

Todos

  • Create/Scaffold activity
  • Create/Scaffold variants source
  • ...

License

MIT

Free Software, Hell Yeah!

php-android-cli's People

Contributors

anandpilania avatar baneeishaque avatar canabadyweb avatar iolaum avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

php-android-cli's Issues

Directory creation not working in Linux

When the app creates the files it doesn't create a proper directory, it just generates individual files with the names of the paths they are supposed to be in,names such as "Project\app\src\main\AndroidManifest.xml".

Edit: I used the latest release phar file. I think latest changes in your code are not reflected in your latest release.

Errors using php-android-cli on fedora linux

I tried to use the project but encountered the following errors:

# Downloaded phpandroid.phar put in a folder inside $PATH and made it executable
$ phpandroid.phar create NewPipeC org.schabi.newpipe
/usr/bin/env: ‘php\r’: No such file or directory

After some googling I found this SO answer so I did:

$ tr -d '\15' < phpandroid.phar > phpandroid
$ chmod u+x phpandroid

and tried again:

$ phpandroid create NewPipeC org.schabi.newpipe
PHP Fatal error:  Uncaught PharException: phar "/home/iolaum/.local/bin/phpandroid" SHA1 signature could not be verified: broken signature in /home/iolaum/.local/bin/phpandroid:4
Stack trace:
#0 /home/iolaum/.local/bin/phpandroid(4): Phar::mapPhar()
#1 {main}
  thrown in /home/iolaum/.local/bin/phpandroid on line 4

at which point I gave up.

Environment details:

$ php -v
PHP 7.3.10 (cli) (built: Sep 24 2019 09:20:18) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.10, Copyright (c) 1998-2018 Zend Technologies
$ lsb_release -a
LSB Version:	:core-4.1-amd64:core-4.1-noarch
Distributor ID:	Fedora
Description:	Fedora release 30 (Thirty)
Release:	30
Codename:	Thirty

shebang incorrect in v1.0.0 causes CLI console error

The latest release v1.0.0 causes a console error when trying to run phpandroid.phar

I downloaded the latest release, and placed it in /usr/bin as phpandroid, then tried to run it in a bash shell:

    noscere@bertram:~$ phpandroid
    /usr/bin/env: ‘php\r’: No such file or directory

A simple hexedit of the phpandroid.phar shows that the hashbang/shebang line has windows type file endings 0D0A /r/n (instead of just 0A or /n) and so it is interpretting the shebang as #!/usr/bin/env/php\r instead of #!/usr/bin/env php.

Unfortunately (for me) I couldn't just hexedit the line ending, changing it to 0A0A (cannot remove a byte, only change it, so effectively this adds a blank line with a unix line-ending character) because that breaks the SHA1 file signature.

I also tried to phar extract the archive and re-pack it with phar pack -b '#!/usr/bin/env php' -f phpandroid.phar * but this does not even insert a shebang at all? (again, viewing with hexedit shows no shebang where there should be one). In the end I downloaded the source and re-compiled my own binary using cd tasks && php generate_phar.php, which added the shebang correctly formatted with proper line ending.

For curiosity-sake, I delved into the code of phar.phar; the section which adds/modifies the hashbang is adding '/n' to the line if a new-line is not present; so I can only assume that the release was built on a windows machine and the /usr/bin/env php line at the top of stub.php had the wrong line ending?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.