How to run Laravel without Artisan?

前端 未结 11 2138
不思量自难忘°
不思量自难忘° 2020-12-05 03:24

I have PHP with Apache2 and I want to run Laravel Framework without Artisan but I can\'t! Does anyone know how to run Laravel without Artisan?

相关标签:
11条回答
  • 2020-12-05 03:58

    Laravel with Vue.JS

    If you are using vue.js with Laravel and your app is not working without php artisan serve, you need to create a virtual host. This is a simple two-step process for windows.

    Step 1: Update you hosts file at C:\Windows\System32\drivers\etc with,

    127.0.0.1       dev.example #You can rename according to your app
    

    Step 2: Update you vhosts file with,

    I am using Apache which is installed in D:\ so my path for vhosts file is at D:\xampp\apache\conf\extra

    <VirtualHost *>
        DocumentRoot "D:\xampp\htdocs\example\public" ##Your path 
        ServerName dev.example ##Your URL according to what you set in hosts file in step 1 
        <Directory "D:\xampp\htdocs\example\public">  ##Your path      
            Order allow,deny     
            Allow from all   
        </Directory> 
    </VirtualHost>
    

    That's it, now you can just visit your app at http://dev.example/

    0 讨论(0)
  • 2020-12-05 04:01

    Artisan is simply a command line interface. It is made to do things like create and run migrations and automate building certain objects within your Application, etc. Essentially, it's only made to help facilitate creating and working on your Application, not run it.

    If you are having issues actually getting the Application to run, it is likely a problem with either your PHP or Apache, not Artisan.

    0 讨论(0)
  • 2020-12-05 04:01

    For Windows Users Its very easy to change and run laravel projects on your normal project urls :
    1. "server.php" to "index.php" .
    2. copy ".htaccess" from public to root directory.

    there you go with your normal URL .

    localhost/project_name

    0 讨论(0)
  • 2020-12-05 04:01

    For an aternative maybe you can run it under a virtual host. All you need is just create a new virtual host with your project/public directory as a DocumentRoot.

    In my case, I am using XAMPP under Mac OS. These are the steps on how to achieve that:

    1. Enable virtual host config

    Ensure virtual host config was enabled, else you can enable it through this file: /Applications/XAMPP/xamppfiles/etc/httpd.conf

    $ sudo nano /Applications/XAMPP/xamppfiles/etc/httpd.conf
    

    Remove the hash "#" of this following line

    # Include /Applications/XAMPP/etc/extra/httpd-vhosts.conf
    
    1. Add a new virtual host

    $ sudo nano /Applications/XAMPP/xamppfiles/etc/extra/httpd-vhosts.conf

    The add a new virtual host (e.g: newproject.dev)

    # Virtual host of newproject.dev <VirtualHost *:80> ServerName newproject.dev DocumentRoot "/Users/your-username/newproject/public" <Directory "/Users/your-username/newproject/public"> Options Indexes FollowSymLinks Includes execCGI AllowOverride All Require all granted </Directory> </VirtualHost>

    Note: /Users/your-username/newproject/public is the location of your project.

    1. Update your hosts

    $ sudo nano /etc/hosts

    Add this following setting:

    # Host of newproject.dev 127.0.0.1 newproject.dev

    Restart your Apache, go to your browser and your project should be available on http://newproject.dev

    0 讨论(0)
  • 2020-12-05 04:04

    Just Follow 3 Step ;

    1. Change File Name : change serve.php to index.php inside your Project name folder.
    2. Move .htaccess file Bring ".htaccess" file to main root [inside your Project name folder ].
    3. Restart your local server. Your are just 1 click away . Restart all services of xampp or wamp
    4. Enjoy
    0 讨论(0)
  • 2020-12-05 04:08

    I've solved the problem. The problem was in my htaccess and in mod_rewrite (Apache2). Now I can connect to my application only by typing localhost/public..

    If anyone wants to make the application public, the more easy and fastest way is:

    • Rename the "server.php" file in root directory, in "index.php"
    • Move your .htaccess from public folder to root directory
    • Make your directory accessible to Apache2 (set correct file/folder permissions).

    Thanks to all users for help! :)

    Important Edit

    Consider using Apache Virtual Hosts (pointing the virtual host to the /public Laravel folder) instead of renaming server.php to index.php because by doing this you will need to prefix "public/" when you use the Laravel's asset() function in your views.

    When working with other devs, who are using a different configuration, this might be a big problem because they will be able to see the assets while you will not (or viceversa).

    0 讨论(0)
提交回复
热议问题