Laravel - php artisan make:model Project Doesnt Work - php

I need to use this command to create a Model.
And when I do that:
php artisan make:model Project
I recieve
[InvalidArgumentException]
There are no commands defined in the "make" namespace.
So, in the tutorial that i'm following the guy uses this to make a model.
What Should I Do?
So, I discover i'm using laravel 4 and this command doenst exist there.
How Can I build a Model without this make command?

The make:model command is new to Laravel 5 so won't be available to you in 4.
To make a model you can simply create a new file in your models folder with the following code
class MyModel extends \Illuminate\Database\Eloquent\Model {
// Code here
}
There is a package available from Jeffrey Way (who created Laracasts) that has some commands that will generate many things for you, including models, which I found really useful when developing with 4. https://github.com/JeffreyWay/Laravel-4-Generators

To generate Models with artisan in laravel 4 you need install JeffreyWay way's package.
It has amazing generators for your laravel 4 app

Related

Laravel Multi tenancy

In my laravel project I am using multi tenancy. For project related work I am creating a laravel custom artisan command. I am trying to connect with repository model in that artisan command that I am creating. But I could not connect with the database. It says
Database [tenant] not configured.
How to use multi tenancy in my custom artisan command. So that I can use all the needed repository models in custom artisan command. Please suggest.
I assume you are using: hyn/multi-tenant
To run specific commands you could use the tenancy:run command. Lets say you have a command sync:donuts, which needs to be run on tenant id=1.
Then you should use:
php artisan tenancy:run sync:donuts --tenant=1
Read more in the documentation

What is the difference between artisan and composer from the point view of a laravel project?

I didn't know composer before laravel and i encountered them at the same time. So, I can't distinguish the commands of them, but memorize them.
What is the difference between php artisan and composer.phar and also the commands they run?
Can anyone help me on this issue? Thanks..
Composer is a package manager for php and artisan is a command line tool using php
Composer
- download libraries
Artisan
- run scripted commands like you would in bash
The reason to use artisan instead of direct php commands is that you have to implement certain functions so you get an universal feel to the commands. It will help with a lot of things like handling arguments. You could see it as a nice helper for writing great php command line tools.
Once your command is generated, you should fill out the name and
description properties of the class, which will be used when
displaying your command on the list screen.
The fire method will be called when your command is executed. You may
place any command logic in this method.
https://laravel.com/docs/5.0/commands
There is a basic difference in these two commands that they belongs to two different packages.
Composer: composer is a dependency management tool for php. It auto manages dependencies of your project according to your requirements and thus makes your project more distributable.
You don't have to package all the dependencies inside your application. And, if your dependencies are variable it is hard to manage them all within your application. So, composer does it for you.
So, your composer command operates this package. And, it can be used for any project whether it is laravel or other php application.
Artisan: This is the command line utility of Laravel. It comes integrated with your laravel installation.
You can perform operations on your laravel project using its commands. As it is a tool built over php. So, you need to execute its command over php-CLI. That is why you use the php before it.
And, you need to use artisan before it because this is the script name which operates the commands of this tool. If you see your laravel project directory it has a file named artisan inside the root folder. It is the file which bootstraps the laravel's command line code. Or, you can say it is like index.php of directory.
Hope I was helpful.

CodeIgniter : 3.0 database migration through composer

Iam working on CodeIgniter database Migrations.
I create table using Migrate.php controller in my project and it's work fine.
Question is it possible to migrate database using cmd like laravel database Migrations?.
Yes.
You can do it with php index.php tools
Most frameworks have built-in command lines and almost all users of these frameworks have to interact with the command line. CodeIgniter has the base for the command line interface but it’s not implemented by default.
Go through with this tutorial CodeIgniter Migration - tutorials.kode-blog.com

Laravel migration vs model creation

Is
php artisan make:model Test -m
equivalent to
php artisan make:migration create_tests_table --create=tests
?
Does make:model -m create a tests table?
In php artisan make:model Test -m, The -m flag will create a migration file for that model.
In php artisan make:migration create_tests_table --create=tests, the --create flag is the name of the table that will be created.
So yes, the -m option will create a migration file with a name like TIMESTAMP_create_tests_table.php
Update
If you find yourself in a situation when you doubt about commands, you can always run a command like this form your terminal: php artisan help make:model. You'll see an overview with some explenation about the extra options of that specific command.
No they are not equivalent; they are very different. One is creating a model AND also creating a migration while the other is just creating a migration (both migrations include a table called tests). Bear in mind that creating a model and creating a table are not the same thing. From the docs: "The Eloquent ORM included with Laravel provides a beautiful, simple ActiveRecord implementation for working with your database. Each database table has a corresponding "Model" which is used to interact with that table. Models allow you to query for data in your tables, as well as insert new records into the table."
https://laravel.com/docs/5.8/eloquent#defining-models

Using Illuminate Database outside Laravel without PHP Artisan Commands

I'm trying to set up database migrations using Illuminate's Database outside of a Laravel 4.2 project. Everything I'm reading online indicated that it is completely doable to use any Illuminate components outside of Laravel, but the difficulty I'm having is creating the database migrations without using Artisan commands ("php artisan make:migration create_user_table"). If any one could help me out with this, I'd really appreciate it, because I know someone has had to find a solution to the problem before.
Thanks!
If you want to use artisan commands you should include the package of it and configure your application accordingly.
illuminate\database package doesn't provide you and artisan commands to use.

Categories