当前位置: 首页>>代码示例>>PHP>>正文


PHP env函数代码示例

本文整理汇总了PHP中env函数的典型用法代码示例。如果您正苦于以下问题:PHP env函数的具体用法?PHP env怎么用?PHP env使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了env函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: postUserSettings

 public function postUserSettings()
 {
     $error = false;
     if (Request::has('user_id')) {
         $user_id = (int) Auth::user()->user_id;
         $input_id = (int) Request::input('user_id');
         if (Request::input('roles') === null) {
             $roles = [];
         } else {
             $roles = Request::input('roles');
         }
         if ($user_id === $input_id && !in_array(env('ROLE_ADMIN'), $roles, false)) {
             $roles[] = env('ROLE_ADMIN');
             $error = true;
         }
         $editUser = User::find(Request::input('user_id'));
         $editUser->roles()->sync($roles);
         $editUser->save();
         $this->streamingUser->update();
     }
     if ($error) {
         return redirect()->back()->with('error', 'Vous ne pouvez pas enlever le droit admin de votre compte!');
     }
     return redirect()->back();
 }
开发者ID:quentin-sommer,项目名称:WebTv,代码行数:25,代码来源:AdminController.php

示例2: up

 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::create('users', function (Blueprint $table) {
         $table->increments('id');
         $table->string('name');
         $table->string('email')->unique();
         $table->string('password');
         $table->boolean('active');
         $table->boolean('banned');
         $table->string('register_ip');
         $table->string('country_code');
         $table->string('locale');
         $table->string('activation_key');
         $table->boolean('su');
         $table->rememberToken();
         $table->timestamps();
     });
     $user = \Laralum::newUser();
     $user->name = env('USER_NAME', 'admin');
     $user->email = env('USER_EMAIL', 'admin@admin.com');
     $user->password = bcrypt(env('USER_PASSWORD', 'admin123'));
     $user->active = true;
     $user->banned = false;
     $user->register_ip = "";
     $user->country_code = env('USER_COUNTRY_CODE', 'ES');
     $user->locale = env('USER_LOCALE', 'en');
     $user->activation_key = str_random(25);
     $user->su = true;
     $user->save();
 }
开发者ID:ConsoleTVs,项目名称:Laralum,代码行数:35,代码来源:2014_10_12_000000_create_users_table.php

示例3: __construct

 function __construct(Router $router, Response $response)
 {
     $this->router = $router;
     $this->response = $response;
     $this->post = new Lazy($_POST);
     $this->get = new Lazy($_GET);
     $this->server = new Lazy($_SERVER);
     $this->files = new Lazy($_FILES);
     $parsedUrl = parse_url($_SERVER['REQUEST_URI'] ?? '/');
     $url = $parsedUrl['path'];
     $envPrefix = env()->getUrlPrefix();
     // replace environment prefix
     if (strpos($url, $envPrefix) === 0) {
         $url = substr($url, strlen($envPrefix));
     }
     // default url if empty
     if (!$url) {
         $url = '/';
     } else {
         if (strlen($url) > 1 && substr($url, -1) == "/") {
             // add / to beginning
             $url = substr($url, 0, -1);
         }
     }
     $this->url = $url;
 }
开发者ID:pckg,项目名称:framework,代码行数:26,代码来源:Request.php

示例4: register

 public function register()
 {
     $this->app->configure("mail");
     $this->app->register(MailServiceProvider::class);
     $this->app->singleton(MailClerk::class, function () {
         return new MailClerk(app("mailer"));
     });
     $this->app->extend("swift.transport", function (TransportManager $manager) {
         $manager->extend("slack", function () {
             $token = env("SLACKMAIL_APIKEY");
             $channel = env("SLACKMAIL_CHANNEL");
             return new SlackTransport($token, $channel);
         });
         $manager->extend("sendgrid", function () {
             if (class_exists(\SendGrid::class)) {
                 $sendgrid = new \SendGrid(env("SENDGRID_APIKEY"));
                 return new SendGridTransport($sendgrid);
             } else {
                 throw new \Exception("SendGrid class not found. plz install via `composer install sendgrid/sendgrid`");
             }
         });
         $manager->extend("array", function () {
             return new ArrayTransport();
         });
         return $manager;
     });
 }
开发者ID:chatbox-inc,项目名称:mailclerk,代码行数:27,代码来源:MailClerkServiceProvider.php

示例5: run

 public function run()
 {
     if (env('DB_DRIVER') == 'mysql') {
         DB::statement('SET FOREIGN_KEY_CHECKS=0;');
     }
     if (env('DB_DRIVER') == 'mysql') {
         DB::table(config('access.roles_table'))->truncate();
     } else {
         //For PostgreSQL or anything else
         DB::statement("TRUNCATE TABLE " . config('access.roles_table') . " CASCADE");
     }
     //Create admin role, id of 1
     $role_model = config('access.role');
     $admin = new $role_model();
     $admin->name = 'Administrator';
     $admin->all = true;
     $admin->sort = 1;
     $admin->created_at = Carbon::now();
     $admin->updated_at = Carbon::now();
     $admin->save();
     //id = 2
     $role_model = config('access.role');
     $user = new $role_model();
     $user->name = 'User';
     $user->sort = 2;
     $user->created_at = Carbon::now();
     $user->updated_at = Carbon::now();
     $user->save();
     if (env('DB_DRIVER') == 'mysql') {
         DB::statement('SET FOREIGN_KEY_CHECKS=1;');
     }
 }
开发者ID:Interlista,项目名称:HackADev,代码行数:32,代码来源:RoleTableSeeder.php

示例6: isColumnNullable

 public static function isColumnNullable($column_name)
 {
     $instance = new static();
     // create an instance of the model to be able to get the table name
     $answer = DB::select(DB::raw("SELECT IS_NULLABLE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='" . $instance->getTable() . "' AND COLUMN_NAME='" . $column_name . "' AND table_schema='" . env('DB_DATABASE') . "'"))[0];
     return $answer->IS_NULLABLE == 'YES' ? true : false;
 }
开发者ID:Ghitu,项目名称:crud,代码行数:7,代码来源:CrudTrait.php

示例7: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $images = $request->input('images');
     $gallery_name = 'gallery_' . time();
     $directory = 'uploads/' . $gallery_name . '/';
     mkdir($directory, 0755);
     $gallery = Gallery::create(['name' => $gallery_name, 'directory' => $directory]);
     foreach ($images as $image) {
         $url = $image['url'];
         $img = Image::make($url);
         $img->resize(800, null, function ($constraint) {
             $constraint->aspectRatio();
             $constraint->upsize();
         });
         preg_match('/\\.[^\\.]+$/i', $url, $ext);
         $filename = $directory . time() . $ext[0];
         $stream = $img->stream();
         $s3 = Storage::disk('s3');
         $s3->put($filename, $stream->__toString(), 'public');
         $client = $s3->getDriver()->getAdapter()->getClient();
         $public_url = $client->getObjectUrl(env('S3_BUCKET'), $filename);
         $gallery->images()->create(['url' => $public_url]);
     }
     $response = ['message' => 'Images successfully uploaded', 'redirect' => url('gallery', $gallery_name)];
     return response()->json($response);
 }
开发者ID:realnerdo,项目名称:photoshow,代码行数:32,代码来源:GalleriesController.php

示例8: createApplication

 /**
  * Creates the application.
  *
  * @return \Illuminate\Foundation\Application
  */
 public function createApplication()
 {
     $app = (require __DIR__ . '/../bootstrap/app.php');
     $app->make(Illuminate\Contracts\Console\Kernel::class)->bootstrap();
     $this->baseUrl = env('APP_URL');
     return $app;
 }
开发者ID:adiachenko,项目名称:rabbits,代码行数:12,代码来源:TestCase.php

示例9: testConstructor

 /**
  * test applying settings in the constructor
  *
  * @return void
  */
 public function testConstructor()
 {
     $object = new BasicAuthenticate($this->Collection, array('userModel' => 'AuthUser', 'fields' => array('username' => 'user', 'password' => 'password')));
     $this->assertEquals('AuthUser', $object->settings['userModel']);
     $this->assertEquals(array('username' => 'user', 'password' => 'password'), $object->settings['fields']);
     $this->assertEquals(env('SERVER_NAME'), $object->settings['realm']);
 }
开发者ID:angel-mendoza,项目名称:proyecto-pasantia,代码行数:12,代码来源:BasicAuthenticateTest.php

示例10: env

 function env($key)
 {
     if ($key === 'HTTPS') {
         if (isset($_SERVER['HTTPS'])) {
             return !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off';
         }
         return strpos(env('SCRIPT_URI'), 'https://') === 0;
     }
     if ($key === 'SCRIPT_NAME') {
         if (env('CGI_MODE') && isset($_ENV['SCRIPT_URL'])) {
             $key = 'SCRIPT_URL';
         }
     }
     $val = null;
     if (isset($_SERVER[$key])) {
         $val = $_SERVER[$key];
     } elseif (isset($_ENV[$key])) {
         $val = $_ENV[$key];
     } elseif (getenv($key) !== false) {
         $val = getenv($key);
     }
     if ($key === 'REMOTE_ADDR' && $val === env('SERVER_ADDR')) {
         $addr = env('HTTP_PC_REMOTE_ADDR');
         if ($addr !== null) {
             $val = $addr;
         }
     }
     if ($val !== null) {
         return $val;
     }
     return null;
 }
开发者ID:Djtec,项目名称:HumbFramework,代码行数:32,代码来源:Basics.php

示例11: setDomains

 private static function setDomains($domain = false, $subdomain = false)
 {
     if ($domain !== false && $subdomain !== false) {
         // set domain and subdomain manually
         self::$domain = $domain;
         self::$subdomain = $subdomain;
     } else {
         $domain = env('DOMAIN');
         $subdomain = '';
         //set subdomain - parse the actual url
         if (isset($_SERVER['HTTP_HOST'])) {
             $arr = explode('.', $_SERVER['HTTP_HOST']);
             if (count($arr) == 2) {
                 // if the array is only a length of 2, that means it is the domain name plus extension,
                 // eg. nowarena.com, so no subdomain
                 $subdomain = '';
             } else {
                 $subdomain = strtolower($arr[0]);
             }
         }
         // set values based on what was determined in config/app.php
         self::$domain = $domain;
         self::$subdomain = $subdomain;
     }
 }
开发者ID:nowarena,项目名称:homestead,代码行数:25,代码来源:Site.php

示例12: fire

 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     $tasks = Task::where('date', '>=', Carbon::parse(date('d-m-Y')))->where('date', '<=', Carbon::parse(date('d-m-Y'))->addDay(7))->orderBy('date', 'asc')->get();
     \Mail::send('emails.remainder', ['tasks' => $tasks], function ($m) {
         $m->to(env('REMAINDER_EMAIL'), env('REMAINDER_NAME'))->subject('[SUN TASK] Your Task Reminder.');
     });
 }
开发者ID:princesust,项目名称:SUN-TASK,代码行数:12,代码来源:Remainder.php

示例13: sendNotificationEmail

 public function sendNotificationEmail(Group $group, User $user)
 {
     if ($user->verified == 1) {
         // Establish timestamp for notifications from membership data (when was an email sent for the last time?)
         $membership = \App\Membership::where('user_id', '=', $user->id)->where('group_id', "=", $group->id)->firstOrFail();
         $last_notification = $membership->notified_at;
         // find unread discussions since timestamp
         $discussions = QueryHelper::getUnreadDiscussionsSince($user->id, $group->id, $membership->notified_at);
         // find new files since timestamp
         $files = \App\File::where('updated_at', '>', $membership->notified_at)->where('group_id', "=", $group->id)->get();
         // find new members since timestamp
         $users = QueryHelper::getNewMembersSince($user->id, $group->id, $membership->notified_at);
         // find future actions until next 2 weeks, this is curently hardcoded... TODO use the mail sending interval to determine stop date
         $actions = \App\Action::where('start', '>', Carbon::now())->where('stop', '<', Carbon::now()->addWeek()->addWeek())->where('group_id', "=", $group->id)->orderBy('start')->get();
         // we only trigger mail sending if a new action has been **created** since last notfication email.
         // BUT we will send actions for the next two weeks in all cases, IF a mail must be sent
         $actions_count = \App\Action::where('created_at', '>', $membership->notified_at)->where('group_id', "=", $group->id)->count();
         // in all cases update timestamp
         $membership->notified_at = Carbon::now();
         $membership->save();
         // if we have anything, build the message and send
         // removed that : or count($users) > 0
         // because we don't want to be notified just because there is a new member
         if (count($discussions) > 0 or count($files) > 0 or $actions_count > 0) {
             Mail::send('emails.notification', ['user' => $user, 'group' => $group, 'membership' => $membership, 'discussions' => $discussions, 'files' => $files, 'users' => $users, 'actions' => $actions, 'last_notification' => $last_notification], function ($message) use($user, $group) {
                 $message->from(env('MAIL_NOREPLY', 'noreply@example.com'), env('APP_NAME', 'Laravel'))->to($user->email)->subject('[' . env('APP_NAME') . '] ' . trans('messages.news_from_group_email_subject') . ' "' . $group->name . '"');
             });
             return true;
         }
         return false;
     }
 }
开发者ID:philippejadin,项目名称:Mobilizator,代码行数:32,代码来源:AppMailer.php

示例14: addDummyDataToTasks

 private function addDummyDataToTasks()
 {
     $i = 0;
     $this->tasks = array_map(function ($task) use(&$i) {
         return array_merge($task, ['title' => 'a task', 'priority' => 'low', 'isClosed' => false, 'projectPHIDs' => ['x'], 'ownerPHID' => null, 'id' => ++$i, 'auxiliary' => [env('MANIPHEST_STORY_POINTS_FIELD') => $task['points']]]);
     }, $this->tasks);
 }
开发者ID:r8j3,项目名称:phragile,代码行数:7,代码来源:TaskListTest.php

示例15: createGuestPost

 public function createGuestPost(Requests\Bins\CreateGuestBin $request)
 {
     $recaptcha = new ReCaptcha(env('RECAPTCHA_SECRET'));
     $response = $recaptcha->verify($request->input('grc-response'), $_SERVER['REMOTE_ADDR']);
     if (!$response->isSuccess()) {
         session()->flash('error', 'You must prove you are human by completing the catpcha!');
         return redirect()->route('bins.create');
     }
     $description = $request->has('description') && trim($request->input('description')) != '' ? $request->input('description') : null;
     $bin = Bin::create(['title' => $request->input('title'), 'description' => $description, 'visibility' => $request->input('visibility')]);
     $bin->versions()->sync($request->input('versions'));
     $files = [];
     foreach ($request->input('name') as $key => $value) {
         $files[$key]['name'] = $value;
     }
     foreach ($request->input('language') as $key => $value) {
         $files[$key]['language'] = $value;
     }
     foreach ($request->input('code') as $key => $value) {
         $files[$key]['code'] = $value;
     }
     foreach ($files as $item) {
         $type = Type::where('css_class', $item['language'])->first();
         $bin->snippets()->create(['type_id' => $type->id, 'name' => $item['name'], 'code' => $item['code']]);
     }
     session()->flash('success', 'Bin created successfully!');
     return redirect()->route('bin.code', $bin->getRouteKey());
 }
开发者ID:everdaniel,项目名称:LaraBin,代码行数:28,代码来源:BinController.php


注:本文中的env函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。