Hello I would like to create a simple PHP CLI to do some scaffolding. For a new project I am working on, we are using Magento to build an eCommerce store. Magento to comes with many default modules, but you can also create your own and we will have to be creating many custom modules.
I would like to create a simple PHP CLI which can be run to generate a default file path/structure for a module. It would be passed in something like the module name and maybe even path of the application and then generate the template folders and files.
I am new to PHP development, so i think this will be a simple enough project and a good learning experience. However I am having trouble knowing where to start. The end goal would probably be to have it archived in a .phar file that can just be run on the command line.
Any suggestions on how I can get started with this?
Thanks for any help, it is much appreciated.
No reason you can't. PHP in the command line reads the $argv array from the command line.
Here's one of my CLI apps; perhaps it can be instructive: https://github.com/dalecosp/NixArchive/blob/master/archive
Related
I am an amateur programmer. I've played with varoius languages over the years but php is the one I know best and often reach for even when I'm sure a real programmer would say I'm using the wrong tool.
I had a developer build a wordpress site for me with a custom theme. I have subsequently written a couple of plugins in pure php that work just fine.
I am now wishing to add another plugin for my site that is going to require a little more frontend trickery. The last time I did anything like this was long before reactjs existed and I cannot remember much javascript - however I was able to master some ajax with php and have old code I can look at to remind myself.
I have installed node and then react on my windows laptop and have built a few hello-world apps. But I now want to write a plugin that will work on my wordpress install.
I am trying to follow this tutorial https://www.green-box.co.uk/create-a-wordpress-plugin-that-uses-a-react-app/. It says that a prerequisite is to have node installed - which I have done on my plesk server by following the instructions for adding it through the "add/remove components" of my plesk web interface, rather than over command line.
Now when I SSH to my server, cd to the /wp-content/plugins/helloworld/ and type npm create-react-app helloworld I get the error:
nodenv: npm: command not found
The `npm' command exists in these Node versions:
12
14
16
18
I think I'm fundamentally misunderstanding how reactjs works but can't seem to get my head round what to do. Have I got the 'wrong' node installed? Or am I supposed to build the code on my local machine and somehow compile it and upload to my web server? Last time I used javascript it was just dumped in plain text files and referened in the html header like css files. I'm sure it's all quite simple but I'm wondering if I shouldn't just ditch the idea of learning any react and doing it all with vanilla javascript.
Could any of the wise heads out there point me in the right direction with a clue? I'm too old for all this new-fangled techology I'm sure this is how my dad felt when they invented cellphones :(
I downloaded AngularJS 2 'Hello World' program from the site and followed the procedures to run the program. I have successfully executed program in AngularJS 2 without Codeigniter 3.
But in Codeigniter 3 environment i don't know how to run 'Hello World' program.
I have the following questions:
Path to run the commands like npm install and npm start in codeigniter 3.
Where to place the folders and files like app,pakage.json, etc..?
Is it correct to run the project in codeigniter..? Example: http://localhost:port/angular-2-codeigniter-3-project/controller
Help me to work this in codeigniter 3. And also notify me if i missed some procedures to run the program.
Have a look at https://blog.pisyek.com/create-todo-app-with-codeigniter-3-angularjs-part-2/
It is actually a good start to get the intergration working.
In reply to the solution(the answer needed to be expanded): optional is to create a restFul base in codeigniter to deliver the wanted data.
Build the components and elements using (example: angular-cli) and prefill the components with lorem ipsum values. After you have created a full angular application compile it to production and include the scripts to your views. I usually tend to use the template controller by Glenn Stovall because it is robust and dynamic to not overload the pages with unused js files.
I hope this helps you find your solution.
This is just a general question, how does Laravel Artisan able to create proper .php file e.g. make:controller with the correct formatting and line breaks?
Is there a good PHP script which can help one develop similar php codes.
Thanks
Ultimately, Artisan relies on Shell scripts included with Laravel. Which are written in the language of Shell and reside in files ending with the extension .sh. Here is a website that contains more explanation of what those are and how to develop them: https://www.shellscript.sh/ If this is ever unavailable simply searching "How to create a shell script" will get you the answer.
PHP can execute these scripts, for example, when you visit that PHP page in your browser, or you trigger it from the command line, assuming you have PHP installed on your server.
Artisan, is custom built to allow you to extend it with more commands, and there are tutorials available to show you how to do that, but it's a completely separate process from creating custom shell commands.
PHP files are just text files, you can easily create them with any language. Also in Laravel usually used so called stubs, templates for classes like migrations, controllers etc.
Just go and look how as Laravel does that under the hood.
All,
I'm a beginner user of Eclipse. I am currently using it for a PHP project. I am starting to have a lot of PHP files under my project so I created a folder inside the project to relocate some of the files. However this breaks the program because as I move the files the functions calling for those files are not updated to reflect their new location.
Is there a way to do that automatically in Eclipse? I would have thought that it would be a core functionality (but then again, I've never used an IDE before.)
Thanks,
JDelage
No, you can't do that without refactoring the code. A global find/replace could fix the problem for you though.
You can try to delete your .metadata directory.
(after backup)
/YourProjectDirectory/.metadata
And restart your IDE.
Or eventualy try to run eclipse with the param "-clean"
"C:\ecplipse.exe -clean" (from CMD)
In drupal, it's possible to create a "build", also known as "install profile" or "distribution" that basically combines several modules and your settings for them. So the next time you setup the same exact site, you don't have to re-configure all the modules.
Does Joomla have a similar concept, and what is it called? Please reference documentation as well if possible.
The concept is very simple - you just need to get a clean installation, install all the extensions you want and configure them the way you need.
Then it is enough to copy the files and the database to a new location and change the settings in the configuration file (configuration.php). That is all.
It is a very simple process and can easily be automated with a simple php script. I once did an asp.net app which was deploying new installations of joomla within seconds.
You could try something like http://www.akeebabackup.com/
This allows you to take a snapshot of a site and export it anywhere.