laravel5 项目问题

1,当安装了laranve5

  1. 先将项目的storage 的权限修改
  2. app 下面可以定义多个表的对象比如: User.php等等
  3. Http 下面的route.php是路由配置文件
  4. Controllers下面是控制器

2,重定向问题

  • 登录跳转到指向路由: 修改:Auth/AuthController.php的
  • protected $redirectTo = '/admin/listAll';
  • 退出logout 跳转到指向路由问题: 目录下有多个文件可以修改重定向
    • /data0/apache/htdocs/xxx/vendor/laravel/framework/src/Illuminate/Foundation/Auth
      目录下有多个文件可以修改重定向

  当用户登录状态的时候,访问登录页面路由auth/login 重定向到指向文件

    /data0/apache/htdocs/cmqn/app/Http/Middleware 这个目录下几个重定向文件可以修改
    • 当写一个接口,被外部调用的时候,没有权限,可以设置单个路由,可以被外部服务器访问
    • /data0/apache/htdocs/xxx/app/Http/Middleware/VerifyCsrfToken.php
      这个文件添加不需要验证的有路由名
          protected $except = [
              //设置一个不需要CSRF的白名单
      		'callback',
          ];
      
      • 配置数据问题
      .env 
      做配置
      APP_ENV=local
      APP_DEBUG=true
      APP_KEY=base64:xxxxx
      APP_URL=https://xxxx
      
      DB_CONNECTION=mysql
      DB_HOST=127.0.0.1
      DB_PORT=3306
      DB_DATABASE=xxx
      DB_USERNAME=xxx
      DB_PASSWORD=xxx
      
      CACHE_DRIVER=file
      SESSION_DRIVER=file
      QUEUE_DRIVER=sync
      
      REDIS_HOST=127.0.0.1
      REDIS_PASSWORD=null
      REDIS_PORT=6379
      
      MAIL_DRIVER=smtp
      MAIL_HOST=mailtrap.io
      MAIL_PORT=2525
      MAIL_USERNAME=null
      MAIL_PASSWORD=null
      MAIL_ENCRYPTION=null
      
      • nginx 配置问题
      /usr/local/nginx/conf/nginx.conf
      /etc/supervisord.d/nginx.conf
      执行文件/usr/local/nginx/sbin/nginx
      先验证: /usr/local/nginx/sbin/nginx -t
      在重新加载: /usr/local/nginx/sbin/nginx -s reload
      
      1. 配置文件  
      2. /usr/local/nginx/conf/nginx.conf
        里面 include /usr/local/sina_mobile/nginx/conf/conf.d/*.conf;
        加载的事conf下面conf.d/的所有conf文件
      -rw-r--r-- 1 root root 1090 Aug 18 12:46 xx.xx.com.cn.conf
      -rw-r--r-- 1 root root 1087 Aug 25 16:12 xx.xx.xx.com.cn.conf
      每个域名可以有一个固定的配置文件
      
      内容为:
          server {
          listen 80;
          server_name 外网com.cn 内网.com.cn;
          //访问路径
          root "/data0/apache/htdocs/xx/public";
      
          index index.html index.htm index.php;
      
          proxy_intercept_errors on;
          sendfile off;
          charset utf-8;
      
          location / {
              try_files $uri $uri/ /index.php?$query_string;
          }
      
          location = /favicon.ico { access_log off; log_not_found off; }
          location = /robots.txt  { access_log off; log_not_found off; }
      
           access_log /data0/nginx/logs/xx.com.cn_access.log main;
           error_log /data0/nginx/logs/xx.com.cn_error.log;
      
      
          location ~ \.php$ {
              fastcgi_pass   unix:/dev/shm/php-fpm.sock;
              fastcgi_index index.php;
              include fastcgi_params;
              fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
              fastcgi_intercept_errors on;
              fastcgi_connect_timeout 300;
              fastcgi_send_timeout 300;
              fastcgi_read_timeout 300;
          }
      
          location ~ /\.ht {
              deny all;
          }
          location ~ /\.env {
              deny all;
          }
          error_page   404  /404.html;
      }
      

      3,https 问题

      /data0/----/htdocs/----app/Providers/AppServiceProvider.php
           * Bootstrap any application services.
           *
           * @return void
           */
          public function boot()
          {
              //
      		$this->app['request']->server->set('HTTPS',true);
          }
      
      网上多种方式:
           public function boot()
          {
              //
              $this->app['request']->server->set('HTTPS',Request()->server('HTTP_HOST') != 'localhost');
          }
    • 4,控制器自定义

    • use App\Http\Controllers\TodayUrlController;
      比如在某个控制器调用自己的控制器
      use 后,然后$config  = new ConfigController
          $config->方法();
      也可以调用外部函数
      require_once('/data0/xxx/xxx/xxx.php');  
      

        

      

    posted @ 2021-01-22 10:45  pebblecome  阅读(127)  评论(0)    收藏  举报