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.
Related
A while ago i was tasked to program a Typo3 extension to write so called .conf files for the icinga2 montoring tool (has nothing to do with Typo3). Still let me explain some parts of it: Basically the backend user needs to create records of records of specific classes and set values for each records properties. Then i need to process the records to create these .conf files with the specific values with a php script.
I was tasked to use the scheduler in Typo3 for this. And here come the problems: How do i use this? I checked the documentation (https://docs.typo3.org/typo3cms/extensions/scheduler/Introduction/Index.html), but i still can't wrap my head around how to use it for my task. I can easily write an Action in a controller of a class to be executed in the frontend and in turn generate the con files... basically manually without the scheduler. But where do i put my php code to be run by the scheduler? I somehow seem not to understand the basical principle of the scheduler. Can i just run an Action of a specific controller of a class of my extension like i would in the Frontend via the scheduler?
I would suggest you use a command controller for this task.
The documentation shows how to create a command controller, which also may accept arguments.
Command controller tasks can directly be executed by TYPO3 scheduler (see screenshot below)
You may even configure task arguments for command controller tasks in TYPO3 scheduler.
I've acted in accordance with this guid Link.
Then, I created Repos.php file in /app/extensions/command/ And run li3 in command line but do not see the following message:
COMMANDS via app
repos
I see the following text only:
Lithium console started in the development environment. Use the --env=environment key to alter this.
COMMANDS via lithium
create
The `create` command allows you to rapidly develop your models, views, controllers, and tests
by generating the minimum code necessary to test and run your application.
g11n
The `G11n` set of commands deals with the extraction and merging of message templates.
help
Get information about a particular class including methods, properties,
and descriptions.
route
The route command lets you inspect your routes and issue requests against the router.
test
Runs a given set of tests and outputs the results.
See `li3 help COMMAND` for more information on a specific command.
Have I done something wrong?
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
I recently installed laravel framework in my laptop.I installed laravel in my Xampp server's htdocs/laravel/laravel source path
How can I run execute written PHP codes normally in browsers and run execute them out side laravel framework?
That means if I create a new .php file in desktop that will show "hello world". Where I should keep that file or in which folder to show my this individual file run in browser only inside laravel framework.
You can put it inside your public directory. If your application has a domain of localhost you can access it via localhost/script.php. BUT this is extremely ill-advised as you are opening yourself to potential vulnerabilities depending on what your script does.
If it is for testing then fine. Otherwise you will have to put that somewhere in your application say app/scripts/script.php where it cannot be accessed via the browser (the only point of stand-alone scripts in web application is for CRON tasks or for CLI commands). If this is the case, you may want to take a look at http://laravel.com/docs/4.2/commands about writing your own artisan commands.
Simplest solution in make filename.blade.php file.
put it in resources/views/filename.blade.php and execute it using routes routes/web.php
Route::get("/filename", function(){
return view('filename');
});
I would recommend storing that code in a custom library inside of Laravel and including it within a controller.
You can put your PHP file inside your storage/app/public/filename.php folder in your laravel application folder and can run like
your_domain_name/storage/filename.php
Everywhere online talks about Rails when it comes to building assets during slug compilation. Is there a way to do this with the other languages like Node.js or PHP?
I have a situation where I need to compile my javascript files with Closure-Compiler and I created a script that calls the compiler and when it's done, it's call node app.js. Then in your Procfile, you need to call you newly created script. Something like web: ./compile_and_start_server.sh
You can also check for the "prestart" in package.json but this I never tried it.
https://npmjs.org/doc/scripts.html